cfpq_data.graphs.utils.multiple_source_utils#
Utilities for the multiple-source query evaluation.
Functions
|
Returns a fixed-size set of graph vertices for multiple-source evaluation. |
|
Returns a set of graph vertices with the given percent of vertices for multiple-source evaluation. |
|
Returns a set of source vertices loaded from a TXT file. |
Returns a set with the result of multiple-source query evaluation loaded from a TXT file. |
|
Returns a path to the TXT file where the multiple-source query evaluation result will be saved. |
|
|
Returns a path to the TXT file where the set of source vertices will be saved. |
- generate_multiple_source(graph: MultiDiGraph, set_size: int, *, seed: int | None = None) Set[int] [source]#
Returns a fixed-size set of graph vertices for multiple-source evaluation.
- Parameters:
Examples
>>> from cfpq_data import * >>> seed = 42 >>> g = cfpq_data.labeled_two_cycles_graph(42, 29) >>> source_vertices = cfpq_data.generate_multiple_source(g, 10, seed=seed) >>> source_vertices {32, 3, 4, 36, 12, 14, 15, 18, 54, 29}
- Returns:
source_vertices -- The set of sampled source vertices for the given graph.
- Return type:
Set[int]
- generate_multiple_source_percent(graph: MultiDiGraph, percent: float, *, seed: int | None = None) Set[int] [source]#
Returns a set of graph vertices with the given percent of vertices for multiple-source evaluation.
- Parameters:
Examples
>>> from cfpq_data import * >>> g = cfpq_data.labeled_two_cycles_graph(42, 29) >>> g.number_of_nodes() 72 >>> seed = 42 >>> source_vertices = cfpq_data.generate_multiple_source_percent(g, 10.0, seed=seed) >>> source_vertices {32, 4, 36, 14, 15, 18, 29}
- Returns:
source_vertices -- The set of sampled source vertices for the given graph.
- Return type:
Set[int]
- multiple_source_from_txt(path: Path | str) Set[int] [source]#
Returns a set of source vertices loaded from a TXT file.
- Parameters:
path (Union[Path, str]) -- The path to the TXT file with the set of source vertices.
Examples
>>> from cfpq_data import * >>> s = {1, 2, 5, 10} >>> path = multiple_source_to_txt(s, "test.txt") >>> source_vertices = multiple_source_from_txt(path) >>> len(source_vertices) 4
- Returns:
source_vertices -- The loaded set of source vertices.
- Return type:
Set[int]
- multiple_source_result_from_txt(path: Path | str) Set[Tuple[int, int]] [source]#
Returns a set with the result of multiple-source query evaluation loaded from a TXT file.
- Parameters:
path (Union[Path, str]) -- The path to the TXT file with the result of multiple-source query evaluation.
Examples
>>> from cfpq_data import * >>> ms_result = {(1, 1), (1, 3), (2, 2), (3, 1)} >>> path = multiple_source_result_to_txt(ms_result, "test.txt") >>> reachable_pairs = multiple_source_result_from_txt(path) >>> len(reachable_pairs) 4
- multiple_source_result_to_txt(reachable_pairs: Set[Tuple[int, int]], path: Path | str) Path [source]#
Returns a path to the TXT file where the multiple-source query evaluation result will be saved.
- Parameters:
Examples
>>> from cfpq_data import * >>> ms_result = {(1, 1), (1, 3), (2, 2), (3, 1)} >>> path = multiple_source_result_to_txt(ms_result, "test.txt")
- Returns:
path -- Path to a TXT file where the multiple-source query evaluation result will be saved.
- Return type:
Path
- multiple_source_to_txt(source_vertices: Set[int], path: Path | str) Path [source]#
Returns a path to the TXT file where the set of source vertices will be saved.
- Parameters:
Examples
>>> from cfpq_data import * >>> s = {1, 2, 5, 10} >>> path = multiple_source_to_txt(s, "test.txt")
- Returns:
path -- Path to a TXT file where the set of source vertices will be saved.
- Return type:
Path