Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views2 pages

Table Based Test

The document outlines a process for generating test cases from a directed graph using libraries igraph and pandas. It involves loading a graph from an edge list, randomly selecting nodes, and creating test cases based on outgoing and incoming edges, including both true and false scenarios. Finally, the test cases are stored in a pandas DataFrame and the first 40 cases are displayed for review.

Uploaded by

ahmeddhamed179
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Table Based Test

The document outlines a process for generating test cases from a directed graph using libraries igraph and pandas. It involves loading a graph from an edge list, randomly selecting nodes, and creating test cases based on outgoing and incoming edges, including both true and false scenarios. Finally, the test cases are stored in a pandas DataFrame and the first 40 cases are displayed for review.

Uploaded by

ahmeddhamed179
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Library Imports:

 igraph as ig: This is used to handle graph operations. igraph is a library that
allows the creation, manipulation, and analysis of graphs.
 pandas as pd: This is used for handling the test cases in a table format,
making it easier to manage and manipulate data.
 random: This module is used to select random nodes from the graph.
2. Loading the Graph:
 This line loads the graph from an edge list file. The file "D:/Email-Enron.txt"
should contain pairs of nodes that are connected by edges. The graph is
directed (directed=True), meaning edges have a direction (i.e., the email is
sent from one node to another).
3. Initialize Test Case List:
python
Copy code
test_cases = []
 An empty list test_cases is initialized to store the test cases that will be
generated.
4. Node Selection Limit:
python
Copy code
node_limit = 500
 This defines a limit of 500 nodes for the test cases. Although the graph may
contain more nodes, only the first 500 nodes will be considered for
generating test cases.
5. Randomly Select 40 Input Nodes:
The code selects 40 random nodes (from the first 500 nodes or the total number of
nodes if fewer than 500). The random.sample() function ensures the nodes are
selected without repetition.

6. Generate Test Cases for Each Input Node:


Outgoing Edges:

 For each selected input node, the outgoing edges (edges originating from the
input node) are selected using g.es.select(_source=input_node).
 The test case ID is created using the format
"TC{input_node}_{output_node}", where input_node is the source node and
output_node is the target node.
 The expected result is set to True because the edge exists in the graph.
False Test Cases for Missing Outgoing Edges:
 If an input node has no outgoing edges (i.e., len(outgoing_edges) == 0), the
code generates false test cases for every other node in the graph (excluding
the input node itself). These test cases assume no edge exists between the
input node and the other nodes.
Incoming Edges:
 Similarly, the code selects the incoming edges (edges targeting the input
node) using g.es.select(_target=input_node).
 The test case ID is created using the format
"TC{output_node}_{input_node}", where output_node is the source node and
input_node is the target node.
 The expected result is True since the edge exists in the graph.
False Test Cases for Missing Incoming Edges:
 If the input node has no incoming edges (i.e., len(incoming_edges) == 0), the
code generates false test cases for every other node (excluding the input
node itself). These test cases assume no edge exists between the input node
and the other nodes.
7. Convert to DataFrame:
 The test_cases list is converted to a pandas DataFrame to store the test cases
in a structured format. The columns are: "Test Case ID", "Input Node",
"Output Node", and "Expected Result".
8. Display the First 40 Test Cases:
 This line prints the first 40 test cases to the console for quick review.

You might also like