C++ ProblemData
- class ProblemData
Stores the data for a graph problem instance.
Contains node information, adjacency list, and provides methods to create graph objects.
- add_edge(self: ProblemData, u: SupportsInt | SupportsIndex, v: SupportsInt | SupportsIndex) None
Adds an edge between two nodes.
- Parameters:
u (Node) – The ID of the first node.
v (Node) – The ID of the second node.
- add_node(self: ProblemData, node_id: SupportsInt | SupportsIndex) None
Adds a node to the problem data.
- Parameters:
node (Node) – The ID of the node to add.
- create_original_graph(self: ProblemData, problem_type: str, budget: SupportsInt | SupportsIndex, seed: SupportsInt | SupportsIndex, hop_distance: SupportsInt | SupportsIndex = 2147483647) Graph
Creates an original graph from the problem data.
Parameters specify the problem type, number of nodes to remove, seed, and hop distance.
- get_adj_list(self: ProblemData) list[set[int]]
Returns the adjacency list representation of the graph.
- Returns:
Adjacency list where each index contains the neighbors of that node.
- Return type:
vector<NodeSet>
- get_nodes_set(self: ProblemData) set[int]
Returns the set of all nodes.
- Returns:
Set of node IDs.
- Return type:
NodeSet
- num_nodes(self: ProblemData) int
Returns the number of nodes in the problem data.
- Returns:
Number of nodes.
- Return type:
- static read_from_adjacency_list_file(filename: str) ProblemData
Reads problem data from an adjacency list format file.
Adjacency list format: each line represents a node and its neighbors.
- Parameters:
filename (str) – Path to the adjacency list file.
- Returns:
The loaded problem data.
- Return type:
- static read_from_edge_list_format(filename: str) ProblemData
Reads problem data from an edge list format file.
Edge list format: contains a header line with node/edge counts, followed by edge definitions.
- Parameters:
filename (str) – Path to the edge list file.
- Returns:
The loaded problem data.
- Return type: