grape.ensmallen
GRAPE (Graph Processing and Embedding) is a fast graph processing and embedding library, designed to scale with big graphs and to run on both off-the-shelf laptop and desktop computers and High Performance Computing clusters of workstations. The library is written in Rust and Python programming languages and is composed of two main modules: Ensmallen (ENabler of SMALL runtimE and memory Needs) and Embiggen (EMBeddInG GENerator), that run synergistically using parallel computation and efficient data structures.
View Source
""" [GRAPE](https://github.com/AnacletoLAB/grape) (Graph Processing and Embedding) is a fast graph processing and embedding library, designed to scale with big graphs and to run on both off-the-shelf laptop and desktop computers and High Performance Computing clusters of workstations. The library is written in Rust and Python programming languages and is composed of two main modules: [Ensmallen](https://github.com/AnacletoLAB/ensmallen) (ENabler of SMALL runtimE and memory Needs) and [Embiggen](https://github.com/monarch-initiative/embiggen) (EMBeddInG GENerator), that run synergistically using parallel computation and efficient data structures. """ from .ensmallen import preprocessing # pylint: disable=import-error from .ensmallen import Graph # pylint: disable=import-error from .ensmallen import edge_list_utils # pylint: disable=import-error # The import of dataset should ALWAYS be under the imports from the compiled bindings # Because otherwise it generate a Circular import and crash from . import datasets __all__ = ["edge_list_utils", "Graph", "preprocessing", "datasets"]
View Source
from __future__ import annotations from typing import * import numpy as np def add_numeric_id_to_csv(original_csv_path: str, original_csv_separator: Optional[str], original_csv_header: Optional[bool], target_csv_path: str, target_csv_separator: Optional[str], target_csv_header: Optional[bool], target_csv_ids_column: Optional[str], target_csv_ids_column_number: Optional[int], comment_symbol: Optional[str], max_rows_number: Optional[int], rows_to_skip: Optional[int], lines_number: Optional[int], verbose: Optional[bool]) -> int: """Create a new CSV with the lines number added to it. Parameters ---------- original_csv_path: str The path from where to load the original CSV. original_csv_separator: Optional[str] Separator to use for the original CSV. original_csv_header: Optional[bool] Whether the original CSV has an header. target_csv_path: str The path from where to load the target CSV. This cannot be the same as the original CSV. target_csv_separator: Optional[str] Separator to use for the target CSV. If None, the one provided from the original CSV will be used. target_csv_header: Optional[bool] Whether the target CSV has an header. If None, the one provided from the original CSV will be used. target_csv_ids_column: Optional[str] The column name to use for the ids in the target list. target_csv_ids_column_number: Optional[int] The column number to use for the ids in the target list. comment_symbol: Optional[str] The comment symbol to use within the original CSV. max_rows_number: Optional[int] The amount of rows to load from the original CSV. rows_to_skip: Optional[int] The amount of rows to skip from the original CSV. verbose: Optional[bool] Whether to show the loading bar while processing the file. Raises ------- ValueError If there are problems with opening the original or target file. ValueError If the original and target paths are identical.""" pass def are_there_selfloops_in_edge_list(path: str, separator: Optional[str], header: Optional[bool], sources_column: Optional[str], sources_column_number: Optional[int], destinations_column: Optional[str], destinations_column_number: Optional[int], comment_symbol: Optional[str], max_rows_number: Optional[int], rows_to_skip: Optional[int], edges_number: Optional[int], load_edge_list_in_parallel: Optional[bool], verbose: Optional[bool], name: Optional[str]) -> bool: """Return whether there are selfloops in the edge list. Parameters ---------- path: str The path from where to load the edge list. separator: Optional[str] The separator for the rows in the edge list. header: Optional[bool] Whether the edge list has an header. sources_column: Optional[str] The column name to use for the source nodes. sources_column_number: Optional[int] The column number to use for the source nodes. destinations_column: Optional[str] The column name to use for the destination nodes. destinations_column_number: Optional[int] The column number to use for the destination nodes. comment_symbol: Optional[str] The comment symbol to use for the lines to skip. max_rows_number: Optional[int] The number of rows to read at most. Note that this parameter is ignored when reading in parallel. rows_to_skip: Optional[int] Number of rows to skip in the edge list. edges_number: Optional[int] Number of edges in the edge list. load_edge_list_in_parallel: Optional[bool] Whether to execute the task in parallel or sequential. Generally, parallel is preferable. verbose: Optional[bool] Whether to show the loading bar while processing the file. name: Optional[str] The name of the graph to display in the loading bar.""" pass def build_optimal_lists_files(original_node_type_path: Optional[str], original_node_type_list_separator: Optional[str], original_node_types_column_number: Optional[int], original_node_types_column: Optional[str], original_numeric_node_type_ids: Optional[bool], original_minimum_node_type_id: Optional[int], original_node_type_list_header: Optional[bool], original_node_type_list_rows_to_skip: Optional[int], original_node_type_list_max_rows_number: Optional[int], original_node_type_list_comment_symbol: Optional[str], original_load_node_type_list_in_parallel: Optional[bool], original_node_type_list_is_correct: Optional[bool], node_types_number: Optional[int], target_node_type_list_path: Optional[str], target_node_type_list_separator: Optional[str], target_node_type_list_node_types_column_number: Optional[int], target_node_type_list_node_types_column: Optional[str], target_node_type_list_header: Optional[bool], original_node_path: Optional[str], original_node_list_separator: Optional[str], original_node_list_header: Optional[bool], node_list_rows_to_skip: Optional[int], node_list_is_correct: Optional[bool], node_list_max_rows_number: Optional[int], node_list_comment_symbol: Optional[str], default_node_type: Optional[str], original_nodes_column_number: Optional[int], original_nodes_column: Optional[str], original_node_types_separator: Optional[str], original_node_list_node_types_column_number: Optional[int], original_node_list_node_types_column: Optional[str], number_of_nodes: Optional[int], original_minimum_node_id: Optional[int], original_numeric_node_ids: Optional[bool], original_node_list_numeric_node_type_ids: Optional[bool], original_skip_node_types_if_unavailable: Optional[bool], original_load_node_list_in_parallel: Optional[bool], maximum_node_id: Optional[int], target_node_path: Optional[str], target_node_list_separator: Optional[str], target_node_list_header: Optional[bool], target_nodes_column: Optional[str], target_nodes_column_number: Optional[int], target_node_types_separator: Optional[str], target_node_list_node_types_column: Optional[str], target_node_list_node_types_column_number: Optional[int], original_edge_type_path: Optional[str], original_edge_type_list_separator: Optional[str], original_edge_types_column_number: Optional[int], original_edge_types_column: Optional[str], original_numeric_edge_type_ids: Optional[bool], original_minimum_edge_type_id: Optional[int], original_edge_type_list_header: Optional[bool], edge_type_list_rows_to_skip: Optional[int], edge_type_list_max_rows_number: Optional[int], edge_type_list_comment_symbol: Optional[str], load_edge_type_list_in_parallel: Optional[bool], edge_type_list_is_correct: Optional[bool], edge_types_number: Optional[int], target_edge_type_list_path: Optional[str], target_edge_type_list_separator: Optional[str], target_edge_type_list_edge_types_column_number: Optional[int], target_edge_type_list_edge_types_column: Optional[str], target_edge_type_list_header: Optional[bool], original_edge_path: str, original_edge_list_separator: Optional[str], original_edge_list_header: Optional[bool], original_sources_column_number: Optional[int], original_sources_column: Optional[str], original_destinations_column_number: Optional[int], original_destinations_column: Optional[str], original_edge_list_edge_types_column_number: Optional[int], original_edge_list_edge_types_column: Optional[str], default_edge_type: Optional[str], original_weights_column_number: Optional[int], original_weights_column: Optional[str], default_weight: Optional[float], original_edge_list_numeric_node_ids: Optional[bool], skip_weights_if_unavailable: Optional[bool], skip_edge_types_if_unavailable: Optional[bool], edge_list_comment_symbol: Optional[str], edge_list_max_rows_number: Optional[int], edge_list_rows_to_skip: Optional[int], load_edge_list_in_parallel: Optional[bool], edges_number: Optional[int], target_edge_path: str, target_edge_list_separator: Optional[str], verbose: Optional[bool], directed: bool, name: Optional[str]) -> Tuple[Optional[int], int, Optional[int], int]: """TODO: write the docstrin""" pass def convert_directed_edge_list_to_undirected(original_edge_path: str, original_edge_list_separator: Optional[str], original_edge_list_header: Optional[bool], original_sources_column: Optional[str], original_sources_column_number: Optional[int], original_destinations_column: Optional[str], original_destinations_column_number: Optional[int], original_edge_list_edge_type_column: Optional[str], original_edge_list_edge_type_column_number: Optional[int], original_weights_column: Optional[str], original_weights_column_number: Optional[int], target_edge_path: str, target_edge_list_separator: Optional[str], target_edge_list_header: Optional[bool], target_sources_column_number: Optional[int], target_sources_column: Optional[str], target_destinations_column_number: Optional[int], target_destinations_column: Optional[str], target_edge_list_edge_type_column: Optional[str], target_edge_list_edge_type_column_number: Optional[int], target_weights_column: Optional[str], target_weights_column_number: Optional[int], comment_symbol: Optional[str], default_edge_type: Optional[str], default_weight: Optional[float], max_rows_number: Optional[int], rows_to_skip: Optional[int], edges_number: Optional[int], skip_edge_types_if_unavailable: Optional[bool], skip_weights_if_unavailable: Optional[bool], verbose: Optional[bool], name: Optional[str]) -> int: """Create a new undirected edge list from a given directed one by duplicating the undirected edges. Parameters ---------- original_edge_path: str The path from where to load the original edge list. original_edge_list_separator: Optional[str] Separator to use for the original edge list. original_edge_list_header: Optional[bool] Whether the original edge list has an header. original_sources_column: Optional[str] The column name to use to load the sources in the original edges list. original_sources_column_number: Optional[int] The column number to use to load the sources in the original edges list. original_destinations_column: Optional[str] The column name to use to load the destinations in the original edges list. original_destinations_column_number: Optional[int] The column number to use to load the destinations in the original edges list. original_edge_list_edge_type_column: Optional[str] The column name to use for the edge types in the original edges list. original_edge_list_edge_type_column_number: Optional[int] The column number to use for the edge types in the original edges list. original_weights_column: Optional[str] The column name to use for the weights in the original edges list. original_weights_column_number: Optional[int] The column number to use for the weights in the original edges list. target_edge_path: str The path from where to load the target edge list. This must be different from the original edge list path. target_edge_list_separator: Optional[str] Separator to use for the target edge list. If None, the one provided from the original edge list will be used. target_edge_list_header: Optional[bool] Whether the target edge list has an header. If None, the one provided from the original edge list will be used. target_sources_column: Optional[str] The column name to use to load the sources in the target edges list. If None, the one provided from the original edge list will be used. target_sources_column_number: Optional[int] The column number to use to load the sources in the target edges list. If None, the one provided from the original edge list will be used. target_destinations_column: Optional[str] The column name to use to load the destinations in the target edges list. If None, the one provided from the original edge list will be used. target_destinations_column_number: Optional[int] The column number to use to load the destinations in the target edges list. If None, the one provided from the original edge list will be used. target_edge_list_edge_type_column: Optional[str] The column name to use for the edge types in the target edges list. If None, the one provided from the original edge list will be used. target_edge_list_edge_type_column_number: Optional[int] The column number to use for the edge types in the target edges list. If None, the one provided from the original edge list will be used. target_weights_column: Optional[str] The column name to use for the weights in the target edges list. If None, the one provided from the original edge list will be used. target_weights_column_number: Optional[int] The column number to use for the weights in the target edges list. If None, the one provided from the original edge list will be used. comment_symbol: Optional[str] The comment symbol to use within the original edge list. default_edge_type: Optional[str] The default edge type to use within the original edge list. default_weight: Optional[float] The default weight to use within the original edge list. max_rows_number: Optional[int] The amount of rows to load from the original edge list. rows_to_skip: Optional[int] The amount of rows to skip from the original edge list. edges_number: Optional[int] The expected number of edges. It will be used for the loading bar. skip_edge_types_if_unavailable: Optional[bool] Whether to automatically skip the edge types if they are not available. skip_weights_if_unavailable: Optional[bool] Whether to automatically skip the weights if they are not available. verbose: Optional[bool] Whether to show the loading bar while processing the file. name: Optional[str] The name of the graph to display in the loading bar. Raises ------- ValueError If there are problems with opening the original or target file. ValueError If the original and target paths are identical.""" pass def convert_edge_list_to_numeric(original_node_path: Optional[str], original_node_list_separator: Optional[str], original_node_list_header: Optional[bool], node_list_rows_to_skip: Optional[int], node_list_is_correct: Optional[bool], node_list_max_rows_number: Optional[int], node_list_comment_symbol: Optional[str], original_nodes_column_number: Optional[int], original_nodes_column: Optional[str], number_of_nodes: Optional[int], original_minimum_node_id: Optional[int], original_numeric_node_ids: Optional[bool], original_load_node_list_in_parallel: Optional[bool], original_edge_type_path: Optional[str], original_edge_types_column_number: Optional[int], original_edge_types_column: Optional[str], edge_types_number: Optional[int], original_numeric_edge_type_ids: Optional[bool], original_minimum_edge_type_id: Optional[int], original_edge_type_list_separator: Optional[str], original_edge_type_list_header: Optional[bool], edge_type_list_rows_to_skip: Optional[int], edge_type_list_is_correct: Optional[bool], edge_type_list_max_rows_number: Optional[int], edge_type_list_comment_symbol: Optional[str], load_edge_type_list_in_parallel: Optional[bool], original_edge_path: str, original_edge_list_separator: Optional[str], original_edge_list_header: Optional[bool], original_sources_column_number: Optional[int], original_sources_column: Optional[str], original_destinations_column_number: Optional[int], original_destinations_column: Optional[str], original_edge_list_edge_types_column: Optional[str], original_edge_list_edge_types_column_number: Optional[int], original_weights_column: Optional[str], original_weights_column_number: Optional[int], target_edge_path: str, target_edge_list_separator: Optional[str], target_edge_list_header: Optional[bool], target_sources_column: Optional[str], target_sources_column_number: Optional[int], target_destinations_column: Optional[str], target_destinations_column_number: Optional[int], target_edge_list_edge_types_column: Optional[str], target_edge_list_edge_types_column_number: Optional[int], target_weights_column: Optional[str], target_weights_column_number: Optional[int], target_node_path: Optional[str], target_node_list_separator: Optional[str], target_node_list_header: Optional[bool], target_nodes_column: Optional[str], target_nodes_column_number: Optional[int], target_edge_type_list_path: Optional[str], target_edge_type_list_separator: Optional[str], target_edge_type_list_header: Optional[bool], target_edge_type_list_edge_types_column: Optional[str], target_edge_type_list_edge_types_column_number: Optional[int], comment_symbol: Optional[str], default_edge_type: Optional[str], default_weight: Optional[float], max_rows_number: Optional[int], rows_to_skip: Optional[int], edges_number: Optional[int], skip_edge_types_if_unavailable: Optional[bool], skip_weights_if_unavailable: Optional[bool], directed: bool, verbose: Optional[bool], name: Optional[str]) -> Tuple[int, Optional[int]]: """Create a new edge list starting from given one with node IDs densified. Parameters ---------- original_edge_path: str The path from where to load the original edge list. original_edge_list_separator: Optional[str] Separator to use for the original edge list. original_edge_list_header: Optional[bool] Whether the original edge list has an header. original_sources_column: Optional[str] The column name to use to load the sources in the original edges list. original_sources_column_number: Optional[int] The column number to use to load the sources in the original edges list. original_destinations_column: Optional[str] The column name to use to load the destinations in the original edges list. original_destinations_column_number: Optional[int] The column number to use to load the destinations in the original edges list. original_edge_list_edge_types_column: Optional[str] The column name to use for the edge types in the original edges list. original_edge_list_edge_types_column_number: Optional[int] The column number to use for the edge types in the original edges list. original_weights_column: Optional[str] The column name to use for the weights in the original edges list. original_weights_column_number: Optional[int] The column number to use for the weights in the original edges list. target_edge_path: str The path from where to load the target edge list. This must be different from the original edge list path. target_edge_list_separator: Optional[str] Separator to use for the target edge list. If None, the one provided from the original edge list will be used. target_edge_list_header: Optional[bool] Whether the target edge list has an header. If None, the one provided from the original edge list will be used. target_sources_column: Optional[str] The column name to use to load the sources in the target edges list. If None, the one provided from the original edge list will be used. target_sources_column_number: Optional[int] The column number to use to load the sources in the target edges list. If None, the one provided from the original edge list will be used. target_destinations_column: Optional[str] The column name to use to load the destinations in the target edges list. If None, the one provided from the original edge list will be used. target_destinations_column_number: Optional[int] The column number to use to load the destinations in the target edges list. If None, the one provided from the original edge list will be used. target_edge_list_edge_types_column: Optional[str] The column name to use for the edge types in the target edges list. If None, the one provided from the original edge list will be used. target_edge_list_edge_types_column_number: Optional[int] The column number to use for the edge types in the target edges list. If None, the one provided from the original edge list will be used. target_weights_column: Optional[str] The column name to use for the weights in the target edges list. If None, the one provided from the original edge list will be used. target_weights_column_number: Optional[int] The column number to use for the weights in the target edges list. If None, the one provided from the original edge list will be used. target_node_path: Optional[str] The optional name for the node list to be written out. target_node_list_separator: Optional[str] The separator to use for the node list. target_node_list_header: Optional[bool] Whether to add the header to the node list. target_nodes_column: Optional[str] The column name for the node names. target_nodes_column_number: Optional[int] The column number for the node names. target_node_ids_column: Optional[str] The column name for the node IDs. target_node_ids_column_number: Optional[int] The column number for the node IDs. target_edge_type_list_path: Optional[str] The optional path where to store the parsed edge types. target_edge_type_list_edge_types_column_number: Optional[int] The column number where to store the edge type names. target_edge_type_list_edge_types_column: Optional[str] The column name where to store the edge type names. target_edge_types_ids_column_number: Optional[int] The column number where to the store the edge type IDs. target_edge_types_ids_column: Optional[str] The column name where to store the edge type IDs. comment_symbol: Optional[str] The comment symbol to use within the original edge list. default_edge_type: Optional[str] The default edge type to use within the original edge list. default_weight: Optional[float] The default weight to use within the original edge list. max_rows_number: Optional[int] The amount of rows to load from the original edge list. rows_to_skip: Optional[int] The amount of rows to skip from the original edge list. edges_number: Optional[int] The expected number of edges. It will be used for the loading bar. skip_edge_types_if_unavailable: Optional[bool] Whether to automatically skip the edge types if they are not available. skip_weights_if_unavailable: Optional[bool] Whether to automatically skip the weights if they are not available. verbose: Optional[bool] Whether to show the loading bar while processing the file. name: Optional[str] The name of the graph to display in the loading bar. Raises ------- ValueError If there are problems with opening the original or target file. ValueError If the original and target paths are identical.""" pass def densify_sparse_numeric_edge_list(maximum_node_id: Optional[int], original_edge_path: str, original_edge_list_separator: Optional[str], original_edge_list_header: Optional[bool], original_sources_column: Optional[str], original_sources_column_number: Optional[int], original_destinations_column: Optional[str], original_destinations_column_number: Optional[int], original_edge_list_edge_types_column: Optional[str], original_edge_list_edge_types_column_number: Optional[int], original_weights_column: Optional[str], original_weights_column_number: Optional[int], original_edge_type_path: Optional[str], original_edge_types_column_number: Optional[int], original_edge_types_column: Optional[str], edge_types_number: Optional[int], original_numeric_edge_type_ids: Optional[bool], original_minimum_edge_type_id: Optional[int], original_edge_type_list_separator: Optional[str], original_edge_type_list_header: Optional[bool], edge_type_list_rows_to_skip: Optional[int], edge_type_list_is_correct: Optional[bool], edge_type_list_max_rows_number: Optional[int], edge_type_list_comment_symbol: Optional[str], load_edge_type_list_in_parallel: Optional[bool], target_edge_path: str, target_edge_list_separator: Optional[str], target_edge_list_header: Optional[bool], target_sources_column: Optional[str], target_sources_column_number: Optional[int], target_destinations_column: Optional[str], target_destinations_column_number: Optional[int], target_edge_list_edge_types_column: Optional[str], target_edge_list_edge_types_column_number: Optional[int], target_weights_column: Optional[str], target_weights_column_number: Optional[int], target_node_path: Optional[str], target_node_list_separator: Optional[str], target_node_list_header: Optional[bool], target_nodes_column: Optional[str], target_nodes_column_number: Optional[int], target_edge_type_list_path: Optional[str], target_edge_type_list_separator: Optional[str], target_edge_type_list_header: Optional[bool], target_edge_type_list_edge_types_column: Optional[str], target_edge_type_list_edge_types_column_number: Optional[int], comment_symbol: Optional[str], default_edge_type: Optional[str], default_weight: Optional[float], max_rows_number: Optional[int], rows_to_skip: Optional[int], edges_number: Optional[int], skip_edge_types_if_unavailable: Optional[bool], skip_weights_if_unavailable: Optional[bool], directed: bool, verbose: Optional[bool], name: Optional[str]) -> Tuple[int, Optional[int]]: """Create a new edge list starting from given numeric one with node IDs densified and returns the number of unique nodes. This method is meant as a solution to parse very large sparse numeric graphs, like for instance ClueWeb. Safety ------ This method will panic if the node IDs are not numeric. TODO: In the future we may handle this case as a normal error. Parameters ---------- maximum_node_id: Optional[int] The maximum node ID present in this graph. If available, optimal memory allocation will be used. original_edge_path: str The path from where to load the original edge list. original_edge_list_separator: Optional[str] Separator to use for the original edge list. original_edge_list_header: Optional[bool] Whether the original edge list has an header. original_sources_column: Optional[str] The column name to use to load the sources in the original edges list. original_sources_column_number: Optional[int] The column number to use to load the sources in the original edges list. original_destinations_column: Optional[str] The column name to use to load the destinations in the original edges list. original_destinations_column_number: Optional[int] The column number to use to load the destinations in the original edges list. original_edge_list_edge_types_column: Optional[str] The column name to use for the edge types in the original edges list. original_edge_list_edge_types_column_number: Optional[int] The column number to use for the edge types in the original edges list. original_weights_column: Optional[str] The column name to use for the weights in the original edges list. original_weights_column_number: Optional[int] The column number to use for the weights in the original edges list. target_edge_path: str The path from where to load the target edge list. target_edge_list_separator: Optional[str] Separator to use for the target edge list. target_edge_list_header: Optional[bool] Whether the target edge list has an header. target_sources_column: Optional[str] The column name to use to load the sources in the target edges list. target_sources_column_number: Optional[int] The column number to use to load the sources in the target edges list. target_destinations_column: Optional[str] The column name to use to load the destinations in the target edges list. target_destinations_column_number: Optional[int] The column number to use to load the destinations in the target edges list. target_edge_list_edge_types_column: Optional[str] The column name to use for the edge types in the target edges list. target_edge_list_edge_types_column_number: Optional[int] The column number to use for the edge types in the target edges list. target_weights_column: Optional[str] The column name to use for the weights in the target edges list. target_weights_column_number: Optional[int] The column number to use for the weights in the target edges list. comment_symbol: Optional[str] The comment symbol to use within the original edge list. default_edge_type: Optional[str] The default edge type to use within the original edge list. default_weight: Optional[float] The default weight to use within the original edge list. max_rows_number: Optional[int] The amount of rows to load from the original edge list. rows_to_skip: Optional[int] The amount of rows to skip from the original edge list. edges_number: Optional[int] The expected number of edges. It will be used for the loading bar. skip_edge_types_if_unavailable: Optional[bool] Whether to automatically skip the edge types if they are not available. skip_weights_if_unavailable: Optional[bool] Whether to automatically skip the weights if they are not available. verbose: Optional[bool] Whether to show the loading bar while processing the file. name: Optional[str] The name of the graph to display in the loading bar.""" pass def convert_node_list_node_types_to_numeric(original_node_type_path: Optional[str], original_node_type_list_separator: Optional[str], original_node_types_column_number: Optional[int], original_node_types_column: Optional[str], node_types_number: Optional[int], original_numeric_node_type_ids: Optional[bool], original_minimum_node_type_id: Optional[int], original_node_type_list_header: Optional[bool], original_node_type_list_rows_to_skip: Optional[int], original_node_type_list_is_correct: Optional[bool], original_node_type_list_max_rows_number: Optional[int], original_node_type_list_comment_symbol: Optional[str], original_load_node_type_list_in_parallel: Optional[bool], target_node_type_list_path: Optional[str], target_node_type_list_separator: Optional[str], target_node_type_list_header: Optional[bool], target_node_type_list_node_types_column: Optional[str], target_node_type_list_node_types_column_number: Optional[int], original_node_path: str, original_node_list_separator: Optional[str], original_node_list_header: Optional[bool], node_list_rows_to_skip: Optional[int], node_list_max_rows_number: Optional[int], node_list_comment_symbol: Optional[str], default_node_type: Optional[str], original_nodes_column_number: Optional[int], original_nodes_column: Optional[str], original_node_types_separator: Optional[str], original_node_list_node_types_column_number: Optional[int], original_node_list_node_types_column: Optional[str], original_minimum_node_id: Optional[int], original_numeric_node_ids: Optional[bool], original_node_list_numeric_node_type_ids: Optional[bool], original_skip_node_types_if_unavailable: Optional[bool], target_node_path: str, target_node_list_separator: Optional[str], target_node_list_header: Optional[bool], target_nodes_column_number: Optional[int], target_nodes_column: Optional[str], target_node_types_separator: Optional[str], target_node_list_node_types_column_number: Optional[int], target_node_list_node_types_column: Optional[str], number_of_nodes: Optional[int]) -> Tuple[int, Optional[int]]: """""" pass def convert_undirected_edge_list_to_directed(original_edge_path: str, original_edge_list_separator: Optional[str], original_edge_list_header: Optional[bool], original_sources_column: Optional[str], original_sources_column_number: Optional[int], original_destinations_column: Optional[str], original_destinations_column_number: Optional[int], original_edge_list_edge_type_column: Optional[str], original_edge_list_edge_type_column_number: Optional[int], original_weights_column: Optional[str], original_weights_column_number: Optional[int], target_edge_path: str, target_edge_list_separator: Optional[str], target_edge_list_header: Optional[bool], target_sources_column: Optional[str], target_sources_column_number: Optional[int], target_destinations_column: Optional[str], target_destinations_column_number: Optional[int], target_edge_list_edge_type_column: Optional[str], target_edge_list_edge_type_column_number: Optional[int], target_weights_column: Optional[str], target_weights_column_number: Optional[int], comment_symbol: Optional[str], default_edge_type: Optional[str], default_weight: Optional[float], max_rows_number: Optional[int], rows_to_skip: Optional[int], edges_number: Optional[int], skip_edge_types_if_unavailable: Optional[bool], skip_weights_if_unavailable: Optional[bool], verbose: Optional[bool], name: Optional[str]) -> int: """Create a new directed edge list from a given undirected one by duplicating the undirected edges. Parameters ---------- original_edge_path: str The path from where to load the original edge list. original_edge_list_separator: Optional[str] Separator to use for the original edge list. original_edge_list_header: Optional[bool] Whether the original edge list has an header. original_sources_column: Optional[str] The column name to use to load the sources in the original edges list. original_sources_column_number: Optional[int] The column number to use to load the sources in the original edges list. original_destinations_column: Optional[str] The column name to use to load the destinations in the original edges list. original_destinations_column_number: Optional[int] The column number to use to load the destinations in the original edges list. original_edge_list_edge_type_column: Optional[str] The column name to use for the edge types in the original edges list. original_edge_list_edge_type_column_number: Optional[int] The column number to use for the edge types in the original edges list. original_weights_column: Optional[str] The column name to use for the weights in the original edges list. original_weights_column_number: Optional[int] The column number to use for the weights in the original edges list. target_edge_path: str The path from where to load the target edge list. This must be different from the original edge list path. target_edge_list_separator: Optional[str] Separator to use for the target edge list. If None, the one provided from the original edge list will be used. target_edge_list_header: Optional[bool] Whether the target edge list has an header. If None, the one provided from the original edge list will be used. target_sources_column: Optional[str] The column name to use to load the sources in the target edges list. If None, the one provided from the original edge list will be used. target_sources_column_number: Optional[int] The column number to use to load the sources in the target edges list. If None, the one provided from the original edge list will be used. target_destinations_column: Optional[str] The column name to use to load the destinations in the target edges list. If None, the one provided from the original edge list will be used. target_destinations_column_number: Optional[int] The column number to use to load the destinations in the target edges list. If None, the one provided from the original edge list will be used. target_edge_list_edge_type_column: Optional[str] The column name to use for the edge types in the target edges list. If None, the one provided from the original edge list will be used. target_edge_list_edge_type_column_number: Optional[int] The column number to use for the edge types in the target edges list. If None, the one provided from the original edge list will be used. target_weights_column: Optional[str] The column name to use for the weights in the target edges list. If None, the one provided from the original edge list will be used. target_weights_column_number: Optional[int] The column number to use for the weights in the target edges list. If None, the one provided from the original edge list will be used. comment_symbol: Optional[str] The comment symbol to use within the original edge list. default_edge_type: Optional[str] The default edge type to use within the original edge list. default_weight: Optional[float] The default weight to use within the original edge list. max_rows_number: Optional[int] The amount of rows to load from the original edge list. rows_to_skip: Optional[int] The amount of rows to skip from the original edge list. edges_number: Optional[int] The expected number of edges. It will be used for the loading bar. skip_edge_types_if_unavailable: Optional[bool] Whether to automatically skip the edge types if they are not available. skip_weights_if_unavailable: Optional[bool] Whether to automatically skip the weights if they are not available. verbose: Optional[bool] Whether to show the loading bar while processing the file. name: Optional[str] The name of the graph to display in the loading bar.""" pass def filter_duplicates_from_edge_list(original_edge_path: str, original_edge_list_separator: Optional[str], original_edge_list_header: Optional[bool], original_edge_list_sources_column: Optional[str], original_edge_list_sources_column_number: Optional[int], original_edge_list_destinations_column: Optional[str], original_edge_list_destinations_column_number: Optional[int], original_edge_list_edge_type_column: Optional[str], original_edge_list_edge_type_column_number: Optional[int], original_edge_list_weights_column: Optional[str], original_edge_list_weights_column_number: Optional[int], target_edge_path: str, target_edge_list_separator: Optional[str], target_edge_list_header: Optional[bool], target_edge_list_sources_column_number: Optional[int], target_edge_list_sources_column: Optional[str], target_edge_list_destinations_column_number: Optional[int], target_edge_list_destinations_column: Optional[str], target_edge_list_edge_type_column: Optional[str], target_edge_list_edge_type_column_number: Optional[int], target_edge_list_weights_column: Optional[str], target_edge_list_weights_column_number: Optional[int], comment_symbol: Optional[str], default_edge_type: Optional[str], default_weight: Optional[float], max_rows_number: Optional[int], rows_to_skip: Optional[int], edges_number: Optional[int], skip_edge_types_if_unavailable: Optional[bool], skip_weights_if_unavailable: Optional[bool], verbose: Optional[bool], name: Optional[str]): """Create a new edge list from a given one filtering duplicates. Parameters ---------- original_edge_path: str The path from where to load the original edge list. original_edge_list_separator: Optional[str] Separator to use for the original edge list. original_edge_list_header: Optional[bool] Whether the original edge list has an header. original_edge_list_sources_column: Optional[str] The column name to use to load the sources in the original edges list. original_edge_list_sources_column_number: Optional[int] The column number to use to load the sources in the original edges list. original_edge_list_destinations_column: Optional[str] The column name to use to load the destinations in the original edges list. original_edge_list_destinations_column_number: Optional[int] The column number to use to load the destinations in the original edges list. original_edge_list_edge_type_column: Optional[str] The column name to use for the edge types in the original edges list. original_edge_list_edge_type_column_number: Optional[int] The column number to use for the edge types in the original edges list. original_edge_list_weights_column: Optional[str] The column name to use for the weights in the original edges list. original_edge_list_weights_column_number: Optional[int] The column number to use for the weights in the original edges list. target_edge_path: str The path from where to load the target edge list. target_edge_list_separator: Optional[str] Separator to use for the target edge list. target_edge_list_header: Optional[bool] Whether the target edge list has an header. target_edge_list_sources_column: Optional[str] The column name to use to load the sources in the target edges list. target_edge_list_sources_column_number: Optional[int] The column number to use to load the sources in the target edges list. target_edge_list_destinations_column: Optional[str] The column name to use to load the destinations in the target edges list. target_edge_list_destinations_column_number: Optional[int] The column number to use to load the destinations in the target edges list. target_edge_list_edge_type_column: Optional[str] The column name to use for the edge types in the target edges list. target_edge_list_edge_type_column_number: Optional[int] The column number to use for the edge types in the target edges list. target_edge_list_weights_column: Optional[str] The column name to use for the weights in the target edges list. target_edge_list_weights_column_number: Optional[int] The column number to use for the weights in the target edges list. comment_symbol: Optional[str] The comment symbol to use within the original edge list. default_edge_type: Optional[str] The default edge type to use within the original edge list. default_weight: Optional[float] The default weight to use within the original edge list. max_rows_number: Optional[int] The amount of rows to load from the original edge list. rows_to_skip: Optional[int] The amount of rows to skip from the original edge list. edges_number: Optional[int] The expected number of edges. It will be used for the loading bar. skip_edge_types_if_unavailable: Optional[bool] Whether to automatically skip the edge types if they are not available. skip_weights_if_unavailable: Optional[bool] Whether to automatically skip the weights if they are not available. verbose: Optional[bool] Whether to show the loading bar while processing the file. name: Optional[str] The name of the graph to display in the loading bar.""" pass def get_minmax_node_from_numeric_edge_list(path: str, separator: Optional[str], header: Optional[bool], sources_column: Optional[str], sources_column_number: Optional[int], destinations_column: Optional[str], destinations_column_number: Optional[int], comment_symbol: Optional[str], max_rows_number: Optional[int], rows_to_skip: Optional[int], edges_number: Optional[int], load_edge_list_in_parallel: Optional[bool], verbose: Optional[bool], name: Optional[str]) -> Tuple[int, int, int]: """Return minimum and maximum node number from given numeric edge list. Parameters ---------- path: str The path from where to load the edge list. separator: Optional[str] The separator for the rows in the edge list. header: Optional[bool] Whether the edge list has an header. sources_column: Optional[str] The column name to use for the source nodes. sources_column_number: Optional[int] The column number to use for the source nodes. destinations_column: Optional[str] The column name to use for the destination nodes. destinations_column_number: Optional[int] The column number to use for the destination nodes. comment_symbol: Optional[str] The comment symbol to use for the lines to skip. max_rows_number: Optional[int] The number of rows to read at most. Note that this parameter is ignored when reading in parallel. rows_to_skip: Optional[int] Number of rows to skip in the edge list. edges_number: Optional[int] Number of edges in the edge list. load_edge_list_in_parallel: Optional[bool] Whether to execute the task in parallel or sequential. Generally, parallel is preferable. verbose: Optional[bool] Whether to show the loading bar while processing the file. name: Optional[str] The name of the graph to display in the loading bar. Raises ------- ValueError If there are problems with the edge list file. ValueError If the elements in the edge list are not numeric. ValueError If the edge list is empty.""" pass def get_rows_number(file_path: str) -> int: """Return number of rows in given CSV path. Parameters ---------- file_path: str The path from where to load the original CSV. Raises ------- ValueError If there are problems with opening the file.""" pass def get_selfloops_number_from_edge_list(path: str, separator: Optional[str], header: Optional[bool], sources_column: Optional[str], sources_column_number: Optional[int], destinations_column: Optional[str], destinations_column_number: Optional[int], comment_symbol: Optional[str], max_rows_number: Optional[int], rows_to_skip: Optional[int], edges_number: Optional[int], load_edge_list_in_parallel: Optional[bool], verbose: Optional[bool], name: Optional[str]) -> int: """Return number of selfloops in the given edge list. Parameters ---------- path: str The path from where to load the edge list. separator: Optional[str] The separator for the rows in the edge list. header: Optional[bool] Whether the edge list has an header. sources_column: Optional[str] The column name to use for the source nodes. sources_column_number: Optional[int] The column number to use for the source nodes. destinations_column: Optional[str] The column name to use for the destination nodes. destinations_column_number: Optional[int] The column number to use for the destination nodes. comment_symbol: Optional[str] The comment symbol to use for the lines to skip. max_rows_number: Optional[int] The number of rows to read at most. Note that this parameter is ignored when reading in parallel. rows_to_skip: Optional[int] Number of rows to skip in the edge list. edges_number: Optional[int] Number of edges in the edge list. load_edge_list_in_parallel: Optional[bool] Whether to execute the task in parallel or sequential. Generally, parallel is preferable. verbose: Optional[bool] Whether to show the loading bar while processing the file. name: Optional[str] The name of the graph to display in the loading bar.""" pass def is_numeric_edge_list(path: str, separator: Optional[str], header: Optional[bool], sources_column: Optional[str], sources_column_number: Optional[int], destinations_column: Optional[str], destinations_column_number: Optional[int], comment_symbol: Optional[str], max_rows_number: Optional[int], rows_to_skip: Optional[int], edges_number: Optional[int], load_edge_list_in_parallel: Optional[bool], verbose: Optional[bool], name: Optional[str]) -> bool: """Return number of selfloops in the given edge list. Parameters ---------- path: str The path from where to load the edge list. separator: Optional[str] The separator for the rows in the edge list. header: Optional[bool] Whether the edge list has an header. sources_column: Optional[str] The column name to use for the source nodes. sources_column_number: Optional[int] The column number to use for the source nodes. destinations_column: Optional[str] The column name to use for the destination nodes. destinations_column_number: Optional[int] The column number to use for the destination nodes. comment_symbol: Optional[str] The comment symbol to use for the lines to skip. max_rows_number: Optional[int] The number of rows to read at most. Note that this parameter is ignored when reading in parallel. rows_to_skip: Optional[int] Number of rows to skip in the edge list. edges_number: Optional[int] Number of edges in the edge list. load_edge_list_in_parallel: Optional[bool] Whether to execute the task in parallel or sequential. Generally, parallel is preferable. verbose: Optional[bool] Whether to show the loading bar while processing the file. name: Optional[str] The name of the graph to display in the loading bar.""" pass def sort_numeric_edge_list(path: str, target_path: str, separator: Optional[str], header: Optional[bool], sources_column: Optional[str], sources_column_number: Optional[int], destinations_column: Optional[str], destinations_column_number: Optional[int], edge_types_column: Optional[str], edge_types_column_number: Optional[int], rows_to_skip: Optional[int], skip_edge_types_if_unavailable: Optional[bool]): """Sort given numeric edge list in place using the sort command. Parameters ---------- path: str The path from where to load the edge list. target_path: str The where to store the edge list. separator: Optional[str] The separator for the rows in the edge list. header: Optional[bool] Whether the edge list has an header. sources_column: Optional[str] The column name to use for the source nodes. sources_column_number: Optional[int] The column number to use for the source nodes. destinations_column: Optional[str] The column name to use for the destination nodes. destinations_column_number: Optional[int] The column number to use for the destination nodes. edge_types_column: Optional[str] The column name to use for the edge types. edge_types_column_number: Optional[int] The column number to use for the edge types. rows_to_skip: Optional[int] Number of rows to skip in the edge list. skip_edge_types_if_unavailable: Optional[bool] Whether to automatically skip the edge types if they are not available.""" pass def sort_numeric_edge_list_inplace(path: str, separator: Optional[str], header: Optional[bool], sources_column: Optional[str], sources_column_number: Optional[int], destinations_column: Optional[str], destinations_column_number: Optional[int], edge_types_column: Optional[str], edge_types_column_number: Optional[int], rows_to_skip: Optional[int], skip_edge_types_if_unavailable: Optional[bool]): """Sort given numeric edge list in place using the sort command. Parameters ---------- path: str The path from where to load the edge list. separator: Optional[str] The separator for the rows in the edge list. header: Optional[bool] Whether the edge list has an header. sources_column: Optional[str] The column name to use for the source nodes. sources_column_number: Optional[int] The column number to use for the source nodes. destinations_column: Optional[str] The column name to use for the destination nodes. destinations_column_number: Optional[int] The column number to use for the destination nodes. edge_types_column: Optional[str] The column name to use for the edge types. edge_types_column_number: Optional[int] The column number to use for the edge types. rows_to_skip: Optional[int] Number of rows to skip in the edge list. skip_edge_types_if_unavailable: Optional[bool] Whether to automatically skip the edge types if they are not available.""" pass
View Source
class Graph: """This is the main struct in Ensmallen, it allows to load and manipulate Graphs efficently. You are not supposed to directly instantiate this struct but instead you should use the static method `from_csv`, which allows to load the graph from an edge-list. To get information about a loaded graph, you can call the `textual_report` method which generates an human-readable HTML report. By default we use EliasFano to store the Adjacency Matrix, this allows to save memory but is slower than a CSR. For this reason you can use the `enable` method to enable optimizzations which speeds up the operations at the cost of more memory usage. You can check the memory usage in bytes using `get_total_memory_used` and you can get a detailed memory report of each data-structure inside Graph using `memory_stats`. You can pre-compute the memory needed (in bits) to store the adjacency matrix of a Graph with $|E|$ edges and $|V|$ nodes: $$2 |E| + |E| \\left\\lceil \\log_2 \\frac{|V|^2}{|E|} \\right\\rceil$$ Most Graph properties are automatically cached to speed up.""" def dump_edges(self, path: str, **kwargs): """Write to disk the edges (and optionally the metadata) of the graph. Parameters ---------- path: str Path where to save the edges and their metadata. verbose: bool = True Wether to show a loading bar while writing to file. separator: str = "\t" What separator to use while writing out to file. header: bool = True Wether to write out the header of the file. sources_column_number: int = 0 The column number where to write out the file. sources_column: str = "subject" The name of the column where to write out the file. destinations_column_number: int = 1 The column number where to write out the file. destinations_column: str = "object" The name of the column where to write out the file. edge_types_column_number: int = 2 The column number where to write out the file. edges_type_column: str = "label" The name of the column where to write out the file. weights_column_number: int = 3 The column number where to write out the file. weights_column: str = "weight" The name of the column where to write out the file. numeric_node_ids: bool = False whether to save the internal numeric Ids instead of the string names. directed: bool = False whether to save graph as directed or undirected. Raises ------ TODO: update the set of exceptions""" pass def hash(self) -> int: """Returns a 64-bit hash of the graph.""" pass def get_laplacian_coo_matrix(self) -> Tuple[np.ndarray, np.ndarray]: """Return tuple with edge node IDs and edge weights.""" pass def get_random_walk_normalized_laplacian_coo_matrix(self) -> Tuple[np.ndarray, np.ndarray]: """Return tuple with edge node IDs and edge weights.""" pass def get_symmetric_normalized_laplacian_coo_matrix(self) -> Tuple[np.ndarray, np.ndarray]: """Return tuple with edge node IDs and edge weights.""" pass def get_symmetric_normalized_coo_matrix(self) -> Tuple[np.ndarray, np.ndarray]: """Return tuple with edge node IDs and edge weights.""" pass def dump_nodes(self, path: str, **kwargs): """Write to disk the nodes (and optionally the metadata) of the graph. Parameters ---------- path: str Path where to save the nodes and their metadata. verbose: bool = True Wether to show a loading bar while writing to file. separator: str = "\t" What separator to use while writing out to file. header: bool = True Wether to write out the header of the file. nodes_column_number: int = 0 The column number where to write the nodes. nodes_column: str = "id" The name of the column of the nodes. node_types_column_number: int = 1 The column number where to write the node types. nodes_type_column: str = "category" The name of the column of the node types. Raises ------ TODO: update the set of exceptions""" pass def get_subgraphs(self, number_of_nodes_to_sample: int, random_state: int, root_node: Optional[int], node_sampling_method: str, edge_weighting_methods: List[str], add_selfloops_where_missing: Optional[bool], unique: Optional[bool]) -> Tuple[np.ndarray, List[np.ndarray]]: """Return subsampled nodes according to the given method and parameters. Parameters ---------- number_of_nodes_to_sample: int the number of nodes to sample. random_state: int The random state to reproduce the sampling. root_node: Optional[int] The (optional) root node to use to sample. In not provided, a random one is sampled. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. edge_weighting_methods: List[str] The edge weighting methods to use to compute the adjacency matrix. add_selfloops_where_missing: Optional[bool] Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true. unique: Optional[bool] = True Whether to reduce the sampled nodes to a unique set. Raises ------ ValueError If the given node sampling method is not supported. ValueError If any of the given subgraph edge weighting method is not supported. ValueError If the list of requested edge weighting methods is empty. ValueError If the `add_selfloops_where_missing` parameter is provided, but the edge weighting method is not laplacian. Returns ------- Tuple with the sampled nodes and the computed kernels.""" pass def get_edge_ids_from_node_ids(self, node_ids: List[int], add_selfloops_where_missing: Optional[bool], complete: Optional[bool]) -> np.ndarray: """Return subsampled edges connected to the given node Ids. Parameters -------------------- node_ids: Vec<NodeT> List of nodes whose edges are to return. add_selfloops_where_missing: Optional[bool] Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true. complete: Optional[bool] = True Whether to return the edges in both directions (when dealing with an undirected graph). Returns -------------------- Tuple with the sampled nodes and the computed kernels.""" pass def get_sparse_subgraphs(self, number_of_nodes_to_sample: int, random_state: int, root_node: Optional[int], node_sampling_method: str, edge_weighting_methods: List[str], add_selfloops_where_missing: Optional[bool], unique: Optional[bool]) -> Tuple[np.ndarray, List[Tuple[np.ndarray, np.ndarray]], ]: """Return subsampled nodes according to the given method and parameters. Parameters -------------------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to reproduce the sampling. root_node: Optional[int] The (optional) root node to use to sample. In not provided, a random one is sampled. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. edge_weighting_methods: List[str] The edge weighting methods to use to compute the adjacency matrix. add_selfloops_where_missing: Optional[bool] Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true. unique: Optional[bool] = True Whether to reduce the sampled nodes to a unique set. Raises -------------------- ValueError If the given node sampling method is not supported. ValueError If any of the given subgraph edge weighting method is not supported. ValueError If the list of requested edge weighting methods is empty. ValueError If the `add_selfloops_where_missing` parameter is provided, but the edge weighting method is not laplacian. Returns -------------------- Tuple with the sampled nodes and the computed kernels.""" pass def get_sparse_undirected_laplacian_subgraphs(self, number_of_nodes_to_sample: int, random_state: int, root_node: Optional[int], node_sampling_method: str) -> Tuple[np.ndarray, List[Tuple[np.ndarray, np.ndarray]], ]: """Return subsampled nodes and edges using laplacian assuming undirected graph with selfloops. Parameters -------------------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to reproduce the sampling. root_node: Optional[int] The (optional) root node to use to sample. In not provided, a random one is sampled. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. Raises -------------------- TODO: Update Returns -------------------- Tuple with the sampled nodes and the computed kernels.""" pass def get_edge_prediction_subgraphs(self, number_of_nodes_to_sample: int, random_state: int, node_sampling_method: str, edge_weighting_methods: List[str], add_selfloops_where_missing: Optional[bool]) -> Tuple[np.ndarray, List[np.ndarray], np.ndarray, List[np.ndarray], np.ndarray, ]: """Return subsampled nodes according to the given method and parameters. Parameters -------------------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to reproduce the sampling. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. edge_weighting_methods: List[str] The edge weighting methods to use to compute the adjacency matrix. add_selfloops_where_missing: Optional[bool] Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true. Raises -------------------- ValueError If the given node sampling method is not supported. ValueError If any of the given subgraph edge weighting method is not supported. ValueError If the list of requested edge weighting methods is empty. ValueError If the `add_selfloops_where_missing` parameter is provided, but the edge weighting method is not laplacian. Returns -------------------- Tuple with the sampled nodes and the computed kernels.""" pass def get_edge_prediction_subgraphs_from_node_ids(self, number_of_nodes_to_sample: int, random_state: int, source_root_node: int, destination_root_node: int, node_sampling_method: str, edge_weighting_methods: List[str], add_selfloops_where_missing: Optional[bool], unique: Optional[bool]) -> Tuple[np.ndarray, List[np.ndarray], np.ndarray, List[np.ndarray], bool, ]: """Return subsampled nodes according to the given method and parameters. Parameters ---------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to reproduce the sampling. source_root_node: int The source root node to use to sample. In not provided, a random one is sampled. destination_root_node: int The destination root node to use to sample. In not provided, a random one is sampled. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. edge_weighting_methods: List[str] The edge weighting methods to use to compute the adjacency matrix. add_selfloops_where_missing: Optional[bool] Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true. unique: Optional[bool] = True Whether to reduce the sampled nodes to a unique set. Raises ------ ValueError If the given node sampling method is not supported. ValueError If any of the given subgraph edge weighting method is not supported. ValueError If the list of requested edge weighting methods is empty. ValueError If the `add_selfloops_where_missing` parameter is provided, but the edge weighting method is not laplacian. Returns ------- Tuple with the sampled nodes and the computed kernels.""" pass def spanning_arborescence(self, verbose: Optional[bool]) -> np.ndarray: """Returns set of edges forming the spanning tree of given graph. Parameters ---------- verbose: bool = True Wether to show a loading bar. Raises ------ ValueError If the given graph is not undirected. Returns ------- Numpy array of tuples of NodeIds forming the spanning tree. References ---------- This is the implementaiton of the algorithm presented in the paper A Fast, Parallel Spanning Tree Algorithm for Symmetric Multiprocessors by David A. Bader and Guojing Cong.""" pass def random_walks(self, walk_length: int, quantity: int, **kwargs) -> np.ndarray: """Return random walks done on the graph using Rust. Parameters ---------- walk_length: int Maximal length of the random walk. On graphs without traps, all walks have this length. quantity: int Number of nodes to sample. return_weight: float = 1.0 Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper. explore_weight: float = 1.0 Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper. change_edge_type_weight: float = 1.0 Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact. change_node_type_weight: float = 1.0 Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact. random_state: int = 42 random_state to use to reproduce the walks. iterations: int = 1 Number of cycles on the graphs to execute. dense_node_mapping: Dict[int, int] = None Mapping to use for converting sparse walk space into a dense space. This object can be created using the method available from graph called `get_dense_node_mapping` that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. max_neighbours: int = None Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk. Raises ------ TODO: Update raises Returns ------- List of list of walks containing the numeric IDs of nodes.""" pass def complete_walks(self, walk_length: int, **kwargs) -> np.ndarray: """Return complete random walks done on the graph using Rust. Parameters ---------- walk_length: int Maximal length of the random walk. On graphs without traps, all walks have this length. return_weight: float = 1.0 Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper. explore_weight: float = 1.0 Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper. change_edge_type_weight: float = 1.0 Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact. change_node_type_weight: float = 1.0 Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact. random_state: int = 42 random_state to use to reproduce the walks. iterations: int = 1 Number of cycles on the graphs to execute. dense_node_mapping: Dict[int, int] = None Mapping to use for converting sparse walk space into a dense space. This object can be created using the method available from graph called `get_dense_node_mapping` that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. max_neighbours: int = None Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk. Raises ------ TODO: Update raises Returns ------- List of list of walks containing the numeric IDs of nodes.""" pass def get_degree_centrality(self) -> np.ndarray: """Returns vector of unweighted degree centrality for all nodes""" pass def get_weighted_degree_centrality(self) -> np.ndarray: """Returns vector of weighted degree centrality for all nodes""" pass def get_unchecked_closeness_centrality_from_node_id(self, node_id: int) -> float: """Return closeness centrality of the requested node. If the given node ID does not exist in the current graph the method will panic. Parameters ---------- node_id: int The node ID whose closeness centrality is to be computed. verbose: Optional[bool] Whether to show an indicative progress bar. Safety ------ If the given node ID does not exist in the graph the method will panic.""" pass def get_unchecked_weighted_closeness_centrality_from_node_id(self, node_id: int, use_edge_weights_as_probabilities: bool) -> float: """Return closeness centrality of the requested node. If the given node ID does not exist in the current graph the method will panic. Parameters ---------- node_id: int The node ID whose closeness centrality is to be computed. use_edge_weights_as_probabilities: bool Whether to treat the edge weights as probabilities. Safety ------ If the given node ID does not exist in the graph the method will panic.""" pass def get_closeness_centrality(self, verbose: Optional[bool]) -> np.ndarray: """Return closeness centrality for all nodes. Parameters ---------- verbose: Optional[bool] Whether to show an indicative progress bar.""" pass def get_weighted_closeness_centrality(self, use_edge_weights_as_probabilities: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Return closeness centrality for all nodes. Parameters ---------- use_edge_weights_as_probabilities: bool Whether to treat the edge weights as probabilities. verbose: Optional[bool] Whether to show an indicative progress bar. Raises ------- ValueError If the graph does not have weights. ValueError If the graph contains negative weights. ValueError If the user has asked for the weights to be treated as probabilities but the weights are not between 0 and 1.""" pass def get_unchecked_harmonic_centrality_from_node_id(self, node_id: int) -> float: """Return harmonic centrality of the requested node. If the given node ID does not exist in the current graph the method will panic. Parameters ---------- node_id: int The node ID whose harmonic centrality is to be computed. Safety ------ If the given node ID does not exist in the graph the method will panic.""" pass def get_unchecked_weighted_harmonic_centrality_from_node_id(self, node_id: int, use_edge_weights_as_probabilities: bool) -> float: """Return harmonic centrality of the requested node. If the given node ID does not exist in the current graph the method will panic. Parameters ---------- node_id: int The node ID whose harmonic centrality is to be computed. use_edge_weights_as_probabilities: bool Whether to treat the edge weights as probabilities. Safety ------ If the given node ID does not exist in the graph the method will panic.""" pass def get_harmonic_centrality(self, verbose: Optional[bool]) -> np.ndarray: """Return harmonic centrality for all nodes. Parameters ---------- verbose: Optional[bool] Whether to show an indicative progress bar.""" pass def get_weighted_harmonic_centrality(self, use_edge_weights_as_probabilities: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Return harmonic centrality for all nodes. Parameters ---------- use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. verbose: Optional[bool] Whether to show an indicative progress bar.""" pass def get_stress_centrality(self, normalize: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Returns vector of stress centrality for all nodes. Parameters ---------- normalize: Optional[bool] Whether to normalize the values. By default, it is false. verbose: Optional[bool] Whether to show a loading bar. By default, it is true.""" pass def get_betweenness_centrality(self, normalize: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Returns vector of betweenness centrality for all nodes. Parameters ---------- normalize: Optional[bool] Whether to normalize the values. By default, it is false. verbose: Optional[bool] Whether to show a loading bar. By default, it is true.""" pass def get_eigenvector_centrality(self, maximum_iterations_number: Optional[int], tollerance: Optional[float]) -> np.ndarray: """Returns vector with unweighted eigenvector centrality. Parameters ---------- maximum_iterations_number: Optional[int] The maximum number of iterations to consider. tollerance: Optional[float] The maximum error tollerance for convergence.""" pass def get_weighted_eigenvector_centrality(self, maximum_iterations_number: Optional[int], tollerance: Optional[float]) -> np.ndarray: """Returns vector with unweighted eigenvector centrality. Parameters ---------- maximum_iterations_number: Optional[int] The maximum number of iterations to consider. tollerance: Optional[float] The maximum error tollerance for convergence.""" pass def encode_edge(self, src: int, dst: int) -> int: """Return edge value corresponding to given node IDs. Parameters ---------- src: int The source node ID. dst: int The destination node ID.""" pass def decode_edge(self, edge: int) -> Tuple[int, int]: """Returns source and destination nodes corresponding to given edge ID. Parameters ---------- edge: int The edge value to decode.""" pass def get_max_encodable_edge_number(self) -> int: """Return maximum encodable edge number""" pass def get_dense_binary_adjacency_matrix(self) -> np.ndarray: """Returns binary dense adjacency matrix. Beware of using this method on big graphs! It'll use all of your RAM!""" pass def get_dense_weighted_adjacency_matrix(self, weight: Optional[float]) -> np.ndarray: """Returns binary weighted adjacency matrix. Beware of using this method on big graphs! It'll use all of your RAM! Parameters ---------- weight: Optional[float] The weight value to use for absent edges. By default, `0.0`. Raises ------- ValueError If the graph does not have edge weights.""" pass def get_unchecked_breadth_first_search_predecessors_parallel_from_node_id(self, src_node_id: int) -> ShortestPathsResultBFS: """Returns shortest path result for the BFS from given source node ID. Parameters ---------- src_node_id: int Root of the tree of minimum paths. Safety ------ If any of the given node ID does not exist in the graph the method will panic. TODO! Explore chains accelerations!""" pass def get_unchecked_breadth_first_search_distances_parallel_from_node_id(self, src_node_id: int) -> ShortestPathsResultBFS: """Returns shortest path result for the BFS from given source node ID. Parameters ---------- src_node_id: int Root of the tree of minimum paths. Safety ------ If any of the given node ID does not exist in the graph the method will panic. TODO! Explore chains accelerations!""" pass def get_unchecked_breadth_first_search_distances_sequential_from_node_id(self, src_node_id: int) -> ShortestPathsResultBFS: """Returns shortest path result for the BFS from given source node ID. Parameters ---------- src_node_id: int Root of the tree of minimum paths. Safety ------ If any of the given node ID does not exist in the graph the method will panic. TODO! Explore chains accelerations!""" pass def get_unchecked_breadth_first_search_from_node_ids(self, src_node_id: int, dst_node_id: Optional[int], compute_predecessors: Optional[bool], maximal_depth: Optional[int]) -> ShortestPathsResultBFS: """Returns vector of minimum paths distances and vector of nodes predecessors, if requested. Parameters ---------- src_node_id: int Root of the tree of minimum paths. maybe_dst_node_id: Optional[int] Optional target destination. If provided, Dijkstra will stop upon reaching this node. compute_predecessors: Optional[bool] Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal depth to execute the DFS for. Safety ------ If any of the given node IDs does not exist in the graph the method will panic. TODO! Explore chains accelerations!""" pass def get_unchecked_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, maximal_depth: Optional[int]) -> np.ndarray: """Returns minimum path node IDs and distance from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. maximal_depth: Optional[int] The maximal depth to execute the BFS for. Safety ------ If any of the given node IDs does not exist in the graph the method will panic. Raises ------- ValueError If the given node is a selfloop. ValueError If there is no path between the two given nodes.""" pass def get_unchecked_shortest_path_node_names_from_node_ids(self, src_node_id: int, dst_node_id: int, maximal_depth: Optional[int]) -> List[str]: """Returns minimum path node names from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. maximal_depth: Optional[int] The maximal depth to execute the BFS for. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass def get_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, maximal_depth: Optional[int]) -> np.ndarray: """Returns minimum path node names from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. maximal_depth: Optional[int] The maximal depth to execute the BFS for. Raises ------- ValueError If any of the given node IDs do not exist in the current graph.""" pass def get_shortest_path_node_ids_from_node_names(self, src_node_name: str, dst_node_name: str, maximal_depth: Optional[int]) -> np.ndarray: """Returns minimum path node names from given node names. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. maximal_depth: Optional[int] The maximal depth to execute the BFS for. Raises ------- ValueError If any of the given node names do not exist in the current graph.""" pass def get_shortest_path_node_names_from_node_names(self, src_node_name: str, dst_node_name: str, maximal_depth: Optional[int]) -> List[str]: """Returns minimum path node names from given node names. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. maximal_depth: Optional[int] The maximal depth to execute the BFS for. Raises ------- ValueError If any of the given node names do not exist in the current graph.""" pass def get_unchecked_k_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, k: int) -> List[List[int]]: """Return vector of the k minimum paths node IDs between given source node and destination node ID. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. k: int Number of paths to find. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass def get_k_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, k: int) -> List[List[int]]: """Return vector of the k minimum paths node IDs between given source node and destination node ID. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. maximal_depth: Optional[int] The maximal depth to execute the BFS for. k: int Number of paths to find. Raises ------- ValueError If any of the given node IDs does not exist in the graph.""" pass def get_k_shortest_path_node_ids_from_node_names(self, src_node_name: str, dst_node_name: str, k: int) -> List[List[int]]: """Return vector of the k minimum paths node IDs between given source node and destination node name. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. k: int Number of paths to find. Raises ------- ValueError If any of the given node names does not exist in the graph.""" pass def get_k_shortest_path_node_names_from_node_names(self, src_node_name: str, dst_node_name: str, k: int) -> List[List[str]]: """Return vector of the k minimum paths node names between given source node and destination node name. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. k: int Number of paths to find. Raises ------- ValueError If any of the given node names does not exist in the graph.""" pass def get_unchecked_eccentricity_and_most_distant_node_id_from_node_id(self, node_id: int) -> Tuple[int, int]: """Returns unweighted eccentricity of the given node. This method will panic if the given node ID does not exists in the graph. Parameters ---------- node_id: int Node for which to compute the eccentricity. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass def get_unchecked_weighted_eccentricity_from_node_id(self, node_id: int, use_edge_weights_as_probabilities: Optional[bool]) -> float: """Returns weighted eccentricity of the given node. This method will panic if the given node ID does not exists in the graph. Parameters ---------- node_id: int Node for which to compute the eccentricity. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass def get_eccentricity_and_most_distant_node_id_from_node_id(self, node_id: int) -> Tuple[int, int]: """Returns unweighted eccentricity of the given node ID. Parameters ---------- node_id: int Node for which to compute the eccentricity. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Raises ------- ValueError If the given node ID does not exist in the graph.""" pass def get_weighted_eccentricity_from_node_id(self, node_id: int, use_edge_weights_as_probabilities: Optional[bool]) -> float: """Returns weighted eccentricity of the given node ID. Parameters ---------- node_id: int Node for which to compute the eccentricity. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Raises ------- ValueError If the given node ID does not exist in the graph. ValueError If weights are requested to be treated as probabilities but are not between 0 and 1. ValueError If the graph contains negative weights.""" pass def get_eccentricity_from_node_name(self, node_name: str) -> int: """Returns unweighted eccentricity of the given node name. Parameters ---------- node_name: str Node for which to compute the eccentricity. Raises ------- ValueError If the given node name does not exist in the current graph instance.""" pass def get_weighted_eccentricity_from_node_name(self, node_name: str, use_edge_weights_as_probabilities: Optional[bool]) -> float: """Returns weighted eccentricity of the given node name. Parameters ---------- node_name: str Node for which to compute the eccentricity. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Raises ------- ValueError If the given node name does not exist in the graph. ValueError If weights are requested to be treated as probabilities but are not between 0 and 1. ValueError If the graph contains negative weights.""" pass def get_unchecked_dijkstra_from_node_ids(self, src_node_id: int, maybe_dst_node_id: Optional[int], maybe_dst_node_ids: Optional[List[int]], compute_predecessors: Optional[bool], maximal_depth: Optional[int], use_edge_weights_as_probabilities: Optional[bool]) -> ShortestPathsDjkstra: """Returns vector of minimum paths distances and vector of nodes predecessors, if requested. Parameters ---------- src_node_id: int Root of the tree of minimum paths. maybe_dst_node_id: Optional[int] Optional target destination. If provided, Dijkstra will stop upon reaching this node. maybe_dst_node_ids: Optional[List[int]] Optional target destinations. If provided, Dijkstra will stop upon reaching all of these nodes. compute_predecessors: bool Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass def get_unchecked_weighted_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, use_edge_weights_as_probabilities: Optional[bool], maximal_depth: Optional[int]) -> Tuple[float, List[int]]: """Returns minimum path node IDs and distance from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass def get_unchecked_weighted_shortest_path_node_names_from_node_ids(self, src_node_id: int, dst_node_id: int, use_edge_weights_as_probabilities: Optional[bool], maximal_depth: Optional[int]) -> Tuple[float, List[str]]: """Returns minimum path node names from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass def get_weighted_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, use_edge_weights_as_probabilities: Optional[bool], maximal_depth: Optional[int]) -> Tuple[float, List[int]]: """Returns minimum path node names from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. Raises ------- ValueError If any of the given node IDs do not exist in the current graph.""" pass def get_weighted_shortest_path_node_ids_from_node_names(self, src_node_name: str, dst_node_name: str, use_edge_weights_as_probabilities: Optional[bool], maximal_depth: Optional[int]) -> Tuple[float, List[int]]: """Returns minimum path node names from given node names. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. Raises ------- ValueError If any of the given node names do not exist in the current graph.""" pass def get_weighted_shortest_path_node_names_from_node_names(self, src_node_name: str, dst_node_name: str, use_edge_weights_as_probabilities: Optional[bool], maximal_depth: Optional[int]) -> Tuple[float, List[str]]: """Returns minimum path node names from given node names. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. Raises ------- ValueError If any of the given node names do not exist in the current graph.""" pass def get_breadth_first_search_from_node_ids(self, src_node_id: int, dst_node_id: Optional[int], compute_predecessors: Optional[bool], maximal_depth: Optional[int]) -> ShortestPathsResultBFS: """Returns vector of minimum paths distances and vector of nodes predecessors from given source node ID and optional destination node ID. Parameters ---------- src_node_id: int Node ID root of the tree of minimum paths. compute_predecessors: Optional[bool] Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal number of iterations to execute the DFS for. Raises ------- ValueError If the given source node ID does not exist in the current graph. ValueError If the given optional destination node ID does not exist in the current graph.""" pass def get_dijkstra_from_node_ids(self, src_node_id: int, maybe_dst_node_id: Optional[int], maybe_dst_node_ids: Optional[List[int]], compute_predecessors: Optional[bool], maximal_depth: Optional[int], use_edge_weights_as_probabilities: Optional[bool]) -> ShortestPathsDjkstra: """Returns vector of minimum paths distances and vector of nodes predecessors from given source node ID and optional destination node ID. Parameters ---------- src_node_id: int Node ID root of the tree of minimum paths. maybe_dst_node_id: Optional[int] Optional target destination. If provided, Dijkstra will stop upon reaching this node. maybe_dst_node_ids: Optional[List[int]] Optional target destinations. If provided, Dijkstra will stop upon reaching all of these nodes. compute_predecessors: Optional[bool] Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal depth to execute the DFS for. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Raises ------- ValueError If the weights are to be used and the graph does not have weights. ValueError If the given source node ID does not exist in the current graph. ValueError If the given optional destination node ID does not exist in the current graph. ValueError If weights are requested to be treated as probabilities but are not between 0 and 1. ValueError If the graph contains negative weights.""" pass def get_diameter_naive(self, ignore_infinity: Optional[bool], verbose: Optional[bool]) -> float: """Returns diameter of the graph using naive method. Note that there exists the non-naive method for undirected graphs and it is possible to implement a faster method for directed graphs but we still need to get to it, as it will require an updated succinct data structure. Parameters ---------- ignore_infinity: Optional[bool] Whether to ignore infinite distances, which are present when in the graph exist multiple components. verbose: Optional[bool] Whether to show a loading bar. Raises ------- ValueError If the graph does not contain nodes.""" pass def get_diameter(self, ignore_infinity: Optional[bool], verbose: Optional[bool]) -> float: """Returns diameter of the graph. Parameters ---------- ignore_infinity: Optional[bool] Whether to ignore infinite distances, which are present when in the graph exist multiple components. verbose: Optional[bool] Whether to show a loading bar. Raises ------- ValueError If the graph does not contain nodes.""" pass def get_weighted_diameter_naive(self, ignore_infinity: Optional[bool], use_edge_weights_as_probabilities: Optional[bool], verbose: Optional[bool]) -> float: """Returns diameter of the graph using naive method. Note that there exists the non-naive method for undirected graphs and it is possible to implement a faster method for directed graphs but we still need to get to it, as it will require an updated succinct data structure. Parameters ---------- ignore_infinity: Optional[bool] Whether to ignore infinite distances, which are present when in the graph exist multiple components. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. verbose: Optional[bool] Whether to show a loading bar. Raises ------- ValueError If the graph does not contain nodes. ValueError If the graph does not have weights. ValueError If the graph contains negative weights. ValueError If the user has asked for the weights to be treated as probabilities but the weights are not between 0 and 1.""" pass def get_breadth_first_search_from_node_names(self, src_node_name: str, dst_node_name: Optional[str], compute_predecessors: Optional[bool], maximal_depth: Optional[int]) -> ShortestPathsResultBFS: """Returns vector of minimum paths distances and vector of nodes predecessors from given source node name and optional destination node name. Parameters ---------- src_node_name: str Node name root of the tree of minimum paths. dst_node_name: Optional[str] Destination node name. compute_predecessors: Optional[bool] Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal depth to execute the DFS for. Raises ------- ValueError If the weights are to be used and the graph does not have weights. ValueError If the given source node name does not exist in the current graph. ValueError If the given optional destination node name does not exist in the current graph.""" pass def get_dijkstra_from_node_names(self, src_node_name: str, maybe_dst_node_name: Optional[str], maybe_dst_node_names: Optional[List[str]], compute_predecessors: Optional[bool], maximal_depth: Optional[int], use_edge_weights_as_probabilities: Optional[bool]) -> ShortestPathsDjkstra: """Returns vector of minimum paths distances and vector of nodes predecessors from given source node name and optional destination node name. Parameters ---------- src_node_name: str Node name root of the tree of minimum paths. maybe_dst_node_name: Optional[str] Optional target destination node name. If provided, Dijkstra will stop upon reaching this node. maybe_dst_node_names: Optional[List[str]] Optional target destination node names. If provided, Dijkstra will stop upon reaching all of these nodes. compute_predecessors: Optional[bool] Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal depth to execute the DFS for. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Raises ------- ValueError If the weights are to be used and the graph does not have weights. ValueError If the given source node name does not exist in the current graph. ValueError If the given optional destination node name does not exist in the current graph.""" pass def get_bipartite_edges(self, removed_existing_edges: Optional[bool], first_nodes_set: Optional[Set[str]], second_nodes_set: Optional[Set[str]], first_node_types_set: Optional[Set[str]], second_node_types_set: Optional[Set[str]]) -> np.ndarray: """Return vector of tuple of Node IDs that form the edges of the required bipartite graph. Parameters ---------- removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. first_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the first set of nodes of the graph. second_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the second set of nodes of the graph. first_node_types_set: Optional[Set[str]] Optional set of node types to create the first set of nodes of the graph. second_node_types_set: Optional[Set[str]] Optional set of node types to create the second set of nodes of the graph.""" pass def get_bipartite_edge_names(self, removed_existing_edges: Optional[bool], first_nodes_set: Optional[Set[str]], second_nodes_set: Optional[Set[str]], first_node_types_set: Optional[Set[str]], second_node_types_set: Optional[Set[str]]) -> List[List[str]]: """Return vector of tuple of Node IDs that form the edges of the required bipartite graph. Parameters ---------- removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. first_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the first set of nodes of the graph. second_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the second set of nodes of the graph. first_node_types_set: Optional[Set[str]] Optional set of node types to create the first set of nodes of the graph. second_node_types_set: Optional[Set[str]] Optional set of node types to create the second set of nodes of the graph.""" pass def get_star_edges(self, central_node: str, removed_existing_edges: Optional[bool], star_points_nodes_set: Optional[Set[str]], star_points_node_types_set: Optional[Set[str]]) -> np.ndarray: """Return vector of tuple of Node IDs that form the edges of the required star. Parameters ---------- central_node: str Name of the node to use as center of the star. removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. star_points_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the set of star points. star_points_node_types_set: Optional[Set[str]] Optional set of node types to create the set of star points.""" pass def get_star_edge_names(self, central_node: str, removed_existing_edges: Optional[bool], star_points_nodes_set: Optional[Set[str]], star_points_node_types_set: Optional[Set[str]]) -> List[List[str]]: """Return vector of tuple of Node names that form the edges of the required star. Parameters ---------- central_node: str Name of the node to use as center of the star. removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. star_points_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the set of star points. star_points_node_types_set: Optional[Set[str]] Optional set of node types to create the set of star points.""" pass def get_clique_edges(self, directed: Optional[bool], allow_selfloops: Optional[bool], removed_existing_edges: Optional[bool], allow_node_type_set: Optional[Set[str]], allow_node_set: Optional[Set[str]]) -> np.ndarray: """Return vector of tuple of Node IDs that form the edges of the required clique. Parameters ---------- directed: Optional[bool] Whether to return the edges as directed or undirected. By default, equal to the graph. allow_selfloops: Optional[bool] Whether to allow self-loops in the clique. By default, equal to the graph. removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. allow_node_type_set: Optional[Set[str]] Node types to include in the clique. allow_node_set: Optional[Set[str]] Nodes to include i the clique.""" pass def get_clique_edge_names(self, directed: Optional[bool], allow_selfloops: Optional[bool], removed_existing_edges: Optional[bool], allow_node_type_set: Optional[Set[str]], allow_node_set: Optional[Set[str]]) -> List[List[str]]: """Return vector of tuple of Node names that form the edges of the required clique. Parameters ---------- directed: Optional[bool] Whether to return the edges as directed or undirected. By default, equal to the graph. allow_selfloops: Optional[bool] Whether to allow self-loops in the clique. By default, equal to the graph. removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. allow_node_type_set: Optional[Set[str]] Node types to include in the clique. allow_node_set: Optional[Set[str]] Nodes to include i the clique.""" pass def get_unchecked_minimum_preferential_attachment(self) -> float: """Returns the minumum unweighted preferential attachment score. Safety ------ If the graph does not contain nodes, the return value will be undefined.""" pass def get_unchecked_maximum_preferential_attachment(self) -> float: """Returns the maximum unweighted preferential attachment score. Safety ------ If the graph does not contain nodes, the return value will be undefined.""" pass def get_unchecked_weighted_minimum_preferential_attachment(self) -> float: """Returns the minumum weighted preferential attachment score. Safety ------ If the graph does not contain nodes, the return value will be undefined.""" pass def get_unchecked_weighted_maximum_preferential_attachment(self) -> float: """Returns the maximum weighted preferential attachment score. Safety ------ If the graph does not contain nodes, the return value will be undefined.""" pass def get_unchecked_preferential_attachment_from_node_ids(self, source_node_id: int, destination_node_id: int, normalize: bool) -> float: """Returns the unweighted preferential attachment from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. normalize: bool Whether to normalize within 0 to 1. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass def get_preferential_attachment_from_node_ids(self, source_node_id: int, destination_node_id: int, normalize: bool) -> float: """Returns the unweighted preferential attachment from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. normalize: bool Whether to normalize by the square of maximum degree. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass def get_preferential_attachment_from_node_names(self, first_node_name: str, second_node_name: str, normalize: bool) -> float: """Returns the unweighted preferential attachment from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. normalize: bool Whether to normalize by the square of maximum degree. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass def get_unchecked_weighted_preferential_attachment_from_node_ids(self, source_node_id: int, destination_node_id: int, normalize: bool) -> float: """Returns the weighted preferential attachment from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. normalize: bool Whether to normalize within 0 to 1. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass def get_weighted_preferential_attachment_from_node_ids(self, source_node_id: int, destination_node_id: int, normalize: bool) -> float: """Returns the weighted preferential attachment from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. normalize: bool Whether to normalize by the square of maximum degree. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass def get_weighted_preferential_attachment_from_node_names(self, first_node_name: str, second_node_name: str, normalize: bool) -> float: """Returns the weighted preferential attachment from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. normalize: bool Whether to normalize by the square of maximum degree. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass def get_unchecked_jaccard_coefficient_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the Jaccard index for the two given nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass def get_jaccard_coefficient_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the Jaccard index for the two given nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass def get_jaccard_coefficient_from_node_names(self, first_node_name: str, second_node_name: str) -> float: """Returns the Jaccard index for the two given nodes from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass def get_unchecked_adamic_adar_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the Adamic/Adar Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass def get_adamic_adar_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the Adamic/Adar Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass def get_adamic_adar_index_from_node_names(self, first_node_name: str, second_node_name: str) -> float: """Returns the Adamic/Adar Index for the given pair of nodes from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass def get_unchecked_resource_allocation_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the unweighted Resource Allocation Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass def get_unchecked_weighted_resource_allocation_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the weighted Resource Allocation Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass def get_resource_allocation_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the unweighted Resource Allocation Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass def get_resource_allocation_index_from_node_names(self, first_node_name: str, second_node_name: str) -> float: """Returns the unweighted Resource Allocation Index for the given pair of nodes from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass def get_weighted_resource_allocation_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the weighted Resource Allocation Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass def get_weighted_resource_allocation_index_from_node_names(self, first_node_name: str, second_node_name: str) -> float: """Returns the weighted Resource Allocation Index for the given pair of nodes from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass def get_unchecked_all_edge_metrics_from_node_ids(self, source_node_id: int, destination_node_id: int, normalize: bool) -> np.ndarray: """Returns all the implemented edge metrics for the two given node IDs. Specifically, the returned values are: * Adamic Adar * Jaccard coefficient * Resource allocation index * Preferential attachment Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. normalize: bool Whether to normalize within 0 to 1. Safety ------ If the given node IDs do not exist in the graph this method will panic.""" pass def filter_from_ids(self, node_ids_to_keep: Optional[List[int]], node_ids_to_filter: Optional[List[int]], node_type_ids_to_keep: Optional[List[Optional[List[int]]]], node_type_ids_to_filter: Optional[List[Optional[List[int]]]], node_type_id_to_keep: Optional[List[Optional[int]]], node_type_id_to_filter: Optional[List[Optional[int]]], edge_ids_to_keep: Optional[List[int]], edge_ids_to_filter: Optional[List[int]], edge_node_ids_to_keep: Optional[List[Tuple[int, int]]], edge_node_ids_to_filter: Optional[List[Tuple[int, int]]], edge_type_ids_to_keep: Optional[List[Optional[int]]], edge_type_ids_to_filter: Optional[List[Optional[int]]], min_edge_weight: Optional[float], max_edge_weight: Optional[float], filter_singleton_nodes: Optional[bool], filter_singleton_nodes_with_selfloop: Optional[bool], filter_selfloops: Optional[bool], filter_parallel_edges: Optional[bool]) -> Graph: """Returns a **NEW** Graph that does not have the required attributes. Parameters ---------- node_ids_to_keep: Optional[List[int]] List of node IDs to keep during filtering. node_ids_to_filter: Optional[List[int]] List of node IDs to remove during filtering. node_type_ids_to_keep: Optional[List[Optional[List[int]]]] List of node type IDs to keep during filtering. The node types must match entirely the given node types vector provided. node_type_ids_to_filter: Optional[List[Optional[List[int]]]] List of node type IDs to remove during filtering. The node types must match entirely the given node types vector provided. node_type_id_to_keep: Optional[List[Optional[int]]] List of node type IDs to keep during filtering. Any of node types must match with one of the node types given. node_type_id_to_filter: Optional[List[Optional[int]]] List of node type IDs to remove during filtering. Any of node types must match with one of the node types given. edge_ids_to_keep: Optional[List[int]] List of edge IDs to keep during filtering. edge_ids_to_filter: Optional[List[int]] List of edge IDs to remove during filtering. edge_node_ids_to_keep: Optional[List[Tuple[int, int]]] List of tuple of node IDs to keep during filtering. edge_node_ids_to_filter: Optional[List[Tuple[int, int]]] List of tuple of node IDs to remove during filtering. edge_type_ids_to_keep: Optional[List[Optional[int]]] List of edge type IDs to keep during filtering. edge_type_ids_to_filter: Optional[List[Optional[int]]] List of edge type IDs to remove during filtering. min_edge_weight: Optional[float] Minimum edge weight. Values lower than this are removed. max_edge_weight: Optional[float] Maximum edge weight. Values higher than this are removed. filter_singleton_nodes: Optional[bool] Whether to filter out singleton nodes. filter_singleton_nodes_with_selfloop: Optional[bool] Whether to filter out singleton nodes with selfloops. filter_selfloops: Optional[bool] Whether to filter out selfloops. filter_parallel_edges: Optional[bool] Whether to filter out parallel edges. verbose: Optional[bool] Whether to show loading bar while building the graphs.""" pass def filter_from_names(self, node_names_to_keep: Optional[List[str]], node_names_to_filter: Optional[List[str]], node_type_names_to_keep: Optional[List[Optional[List[str]]]], node_type_names_to_filter: Optional[List[Optional[List[str]]]], node_type_name_to_keep: Optional[List[Optional[str]]], node_type_name_to_filter: Optional[List[Optional[str]]], edge_node_names_to_keep: Optional[List[Tuple[str, str]]], edge_node_names_to_filter: Optional[List[Tuple[str, str]]], edge_type_names_to_keep: Optional[List[Optional[str]]], edge_type_names_to_filter: Optional[List[Optional[str]]], min_edge_weight: Optional[float], max_edge_weight: Optional[float], filter_singleton_nodes: Optional[bool], filter_singleton_nodes_with_selfloop: Optional[bool], filter_selfloops: Optional[bool], filter_parallel_edges: Optional[bool]) -> Graph: """Returns a **NEW** Graph that does not have the required attributes. Parameters ---------- node_names_to_keep: Optional[List[str]] List of node names to keep during filtering. node_names_to_filter: Optional[List[str]] List of node names to remove during filtering. node_type_names_to_keep: Optional[List[Optional[List[str]]]] List of node type names to keep during filtering. The node types must match entirely the given node types vector provided. node_type_names_to_filter: Optional[List[Optional[List[str]]]] List of node type names to remove during filtering. The node types must match entirely the given node types vector provided. node_type_name_to_keep: Optional[List[Optional[str]]] List of node type name to keep during filtering. Any of node types must match with one of the node types given. node_type_name_to_filter: Optional[List[Optional[str]]] List of node type name to remove during filtering. Any of node types must match with one of the node types given. edge_node_names_to_keep: Optional[List[Tuple[str, str]]] List of tuple of node names to keep during filtering. edge_node_names_to_filter: Optional[List[Tuple[str, str]]] List of tuple of node names to remove during filtering. edge_type_names_to_keep: Optional[List[Optional[str]]] List of edge type names to keep during filtering. edge_type_names_to_filter: Optional[List[Optional[str]]] List of edge type names to remove during filtering. min_edge_weight: Optional[float] Minimum edge weight. Values lower than this are removed. max_edge_weight: Optional[float] Maximum edge weight. Values higher than this are removed. filter_singleton_nodes: Optional[bool] Whether to filter out singletons. filter_singleton_nodes_with_selfloop: Optional[bool] Whether to filter out singleton nodes with selfloops. filter_selfloops: Optional[bool] Whether to filter out selfloops. filter_parallel_edges: Optional[bool] Whether to filter out parallel edges. verbose: Optional[bool] Whether to show loading bar while building the graphs.""" pass def drop_unknown_node_types(self) -> Graph: """Returns new graph without unknown node types and relative nodes. Note that this method will remove ALL nodes labeled with unknown node type!""" pass def drop_unknown_edge_types(self) -> Graph: """Returns new graph without unknown edge types and relative edges. Note that this method will remove ALL edges labeled with unknown edge type!""" pass def drop_singleton_nodes(self) -> Graph: """Returns new graph without singleton nodes. A node is singleton when does not have neither incoming or outgoing edges.""" pass def drop_singleton_nodes_with_selfloops(self) -> Graph: """Returns new graph without singleton nodes with selfloops. A node is singleton with selfloop when does not have neither incoming or outgoing edges.""" pass def drop_disconnected_nodes(self) -> Graph: """Returns new graph without disconnected nodes. A disconnected node is a node with no connection to any other node.""" pass def drop_selfloops(self) -> Graph: """Returns new graph without selfloops.""" pass def drop_parallel_edges(self) -> Graph: """Returns new graph without parallel edges""" pass @staticmethod def from_csv(node_type_path: Optional[str], node_type_list_separator: Optional[str], node_types_column_number: Optional[int], node_types_column: Optional[str], node_types_ids_column_number: Optional[int], node_types_ids_column: Optional[str], node_types_number: Optional[int], numeric_node_type_ids: Optional[bool], minimum_node_type_id: Optional[int], node_type_list_header: Optional[bool], node_type_list_rows_to_skip: Optional[int], node_type_list_is_correct: Optional[bool], node_type_list_max_rows_number: Optional[int], node_type_list_comment_symbol: Optional[str], load_node_type_list_in_parallel: Optional[bool], node_path: Optional[str], node_list_separator: Optional[str], node_list_header: Optional[bool], node_list_rows_to_skip: Optional[int], node_list_is_correct: Optional[bool], node_list_max_rows_number: Optional[int], node_list_comment_symbol: Optional[str], default_node_type: Optional[str], nodes_column_number: Optional[int], nodes_column: Optional[str], node_types_separator: Optional[str], node_list_node_types_column_number: Optional[int], node_list_node_types_column: Optional[str], node_ids_column: Optional[str], node_ids_column_number: Optional[int], number_of_nodes: Optional[int], minimum_node_id: Optional[int], numeric_node_ids: Optional[bool], node_list_numeric_node_type_ids: Optional[bool], skip_node_types_if_unavailable: Optional[bool], load_node_list_in_parallel: Optional[bool], edge_type_path: Optional[str], edge_types_column_number: Optional[int], edge_types_column: Optional[str], edge_types_ids_column_number: Optional[int], edge_types_ids_column: Optional[str], edge_types_number: Optional[int], numeric_edge_type_ids: Optional[bool], minimum_edge_type_id: Optional[int], edge_type_list_separator: Optional[str], edge_type_list_header: Optional[bool], edge_type_list_rows_to_skip: Optional[int], edge_type_list_is_correct: Optional[bool], edge_type_list_max_rows_number: Optional[int], edge_type_list_comment_symbol: Optional[str], load_edge_type_list_in_parallel: Optional[bool], edge_path: Optional[str], edge_list_separator: Optional[str], edge_list_header: Optional[bool], edge_list_rows_to_skip: Optional[int], sources_column_number: Optional[int], sources_column: Optional[str], destinations_column_number: Optional[int], destinations_column: Optional[str], edge_list_edge_types_column_number: Optional[int], edge_list_edge_types_column: Optional[str], default_edge_type: Optional[str], weights_column_number: Optional[int], weights_column: Optional[str], default_weight: Optional[float], edge_ids_column: Optional[str], edge_ids_column_number: Optional[int], edge_list_numeric_edge_type_ids: Optional[bool], edge_list_numeric_node_ids: Optional[bool], skip_weights_if_unavailable: Optional[bool], skip_edge_types_if_unavailable: Optional[bool], edge_list_is_complete: Optional[bool], edge_list_may_contain_duplicates: Optional[bool], edge_list_is_sorted: Optional[bool], edge_list_is_correct: Optional[bool], edge_list_max_rows_number: Optional[int], edge_list_comment_symbol: Optional[str], edges_number: Optional[int], load_edge_list_in_parallel: Optional[bool], verbose: Optional[bool], may_have_singletons: Optional[bool], may_have_singleton_with_selfloops: Optional[bool], directed: bool, name: Optional[str]) -> Graph: """Return graph renderized from given CSVs or TSVs-like files. Parameters ---------- node_type_path: Optional[str] The path to the file with the unique node type names. node_type_list_separator: Optional[str] The separator to use for the node types file. Note that if this is not provided, one will be automatically detected among the following`: comma, semi-column, tab and space. node_types_column_number: Optional[int] The number of the column of the node types file from where to load the node types. node_types_column: Optional[str] The name of the column of the node types file from where to load the node types. node_types_number: Optional[int] The number of the unique node types. This will be used in order to allocate the correct size for the data structure. numeric_node_type_ids: Optional[bool] Whether the node type names should be loaded as numeric values, i.e. casted from string to a numeric representation. minimum_node_type_id: Optional[int] The minimum node type ID to be used when using numeric node type IDs. node_type_list_header: Optional[bool] Whether the node type file has an header. node_type_list_rows_to_skip: Optional[int] The number of lines to skip in the node types file`: the header is already skipped if it has been specified that the file has an header. node_type_list_is_correct: Optional[bool] Whether the node types file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash. node_type_list_max_rows_number: Optional[int] The maximum number of lines to be loaded from the node types file. node_type_list_comment_symbol: Optional[str] The comment symbol to skip lines in the node types file. Lines starting with this symbol will be skipped. load_node_type_list_in_parallel: Optional[bool] Whether to load the node type list in parallel. Note that when loading in parallel, the internal order of the node type IDs may result changed across different iterations. We are working to get this to be stable. node_path: Optional[str] The path to the file with the unique node names. node_list_separator: Optional[str] The separator to use for the nodes file. Note that if this is not provided, one will be automatically detected among the following`: comma, semi-column, tab and space. node_list_header: Optional[bool] Whether the nodes file has an header. node_list_rows_to_skip: Optional[int] Number of rows to skip in the node list file. node_list_is_correct: Optional[bool] Whether the nodes file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash. node_list_max_rows_number: Optional[int] The maximum number of lines to be loaded from the nodes file. node_list_comment_symbol: Optional[str] The comment symbol to skip lines in the nodes file. Lines starting with this symbol will be skipped. default_node_type: Optional[str] The node type to be used when the node type for a given node in the node file is None. nodes_column_number: Optional[int] The number of the column of the node file from where to load the node names. nodes_column: Optional[str] The name of the column of the node file from where to load the node names. node_types_separator: Optional[str] The node types separator. node_list_node_types_column_number: Optional[int] The number of the column of the node file from where to load the node types. node_list_node_types_column: Optional[str] The name of the column of the node file from where to load the node types. node_ids_column: Optional[str] The name of the column of the node file from where to load the node IDs. node_ids_column_number: Optional[int] The number of the column of the node file from where to load the node IDs number_of_nodes: Optional[int] The expected number of nodes. Note that this must be the EXACT number of nodes in the graph. minimum_node_id: Optional[int] The minimum node ID to be used, when loading the node IDs as numerical. numeric_node_ids: Optional[bool] Whether to load the numeric node IDs as numeric. node_list_numeric_node_type_ids: Optional[bool] Whether to load the node types IDs in the node file to be numeric. skip_node_types_if_unavailable: Optional[bool] Whether to skip the node types without raising an error if these are unavailable. load_node_list_in_parallel: Optional[bool] Whether to load the node list in parallel. When loading in parallel, without node IDs, the nodes may not be loaded in a deterministic order. edge_type_path: Optional[str] The path to the file with the unique edge type names. edge_types_column_number: Optional[int] The number of the column of the edge types file from where to load the edge types. edge_types_column: Optional[str] The name of the column of the edge types file from where to load the edge types. edge_types_number: Optional[int] The number of the unique edge types. This will be used in order to allocate the correct size for the data structure. numeric_edge_type_ids: Optional[bool] Whether the edge type names should be loaded as numeric values, i.e. casted from string to a numeric representation. minimum_edge_type_id: Optional[int] The minimum edge type ID to be used when using numeric edge type IDs. edge_type_list_separator: Optional[str] The separator to use for the edge type list. Note that, if None is provided, one will be attempted to be detected automatically between ';', ',', tab or space. edge_type_list_header: Optional[bool] Whether the edge type file has an header. edge_type_list_rows_to_skip: Optional[int] Number of rows to skip in the edge type list file. edge_type_list_is_correct: Optional[bool] Whether the edge types file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash. edge_type_list_max_rows_number: Optional[int] The maximum number of lines to be loaded from the edge types file. edge_type_list_comment_symbol: Optional[str] The comment symbol to skip lines in the edge types file. Lines starting with this symbol will be skipped. load_edge_type_list_in_parallel: Optional[bool] Whether to load the edge type list in parallel. When loading in parallel, without edge type IDs, the edge types may not be loaded in a deterministic order. edge_path: Optional[str] The path to the file with the edge list. edge_list_separator: Optional[str] The separator to use for the edge list. Note that, if None is provided, one will be attempted to be detected automatically between ';', ',', tab or space. edge_list_header: Optional[bool] Whether the edges file has an header. edge_list_rows_to_skip: Optional[int] Number of rows to skip in the edge list file. sources_column_number: Optional[int] The number of the column of the edges file from where to load the source nodes. sources_column: Optional[str] The name of the column of the edges file from where to load the source nodes. destinations_column_number: Optional[int] The number of the column of the edges file from where to load the destinaton nodes. destinations_column: Optional[str] The name of the column of the edges file from where to load the destinaton nodes. edge_list_edge_types_column_number: Optional[int] The number of the column of the edges file from where to load the edge types. edge_list_edge_types_column: Optional[str] The name of the column of the edges file from where to load the edge types. default_edge_type: Optional[str] The edge type to be used when the edge type for a given edge in the edge file is None. weights_column_number: Optional[int] The number of the column of the edges file from where to load the edge weights. weights_column: Optional[str] The name of the column of the edges file from where to load the edge weights. default_weight: Optional[float] The edge weight to be used when the edge weight for a given edge in the edge file is None. edge_ids_column: Optional[str] The name of the column of the edges file from where to load the edge IDs. edge_ids_column_number: Optional[int] The number of the column of the edges file from where to load the edge IDs. edge_list_numeric_edge_type_ids: Optional[bool] Whether to load the edge type IDs as numeric from the edge list. edge_list_numeric_node_ids: Optional[bool] Whether to load the edge node IDs as numeric from the edge list. skip_weights_if_unavailable: Optional[bool] Whether to skip the weights without raising an error if these are unavailable. skip_edge_types_if_unavailable: Optional[bool] Whether to skip the edge types without raising an error if these are unavailable. edge_list_is_complete: Optional[bool] Whether to consider the edge list as complete, i.e. the edges are presented in both directions when loading an undirected graph. edge_list_may_contain_duplicates: Optional[bool] Whether the edge list may contain duplicates. If the edge list surely DOES NOT contain duplicates, a validation step may be skipped. By default, it is assumed that the edge list may contain duplicates. edge_list_is_sorted: Optional[bool] Whether the edge list is sorted. Note that a sorted edge list has the minimal memory peak, but requires the nodes number and the edges number. edge_list_is_correct: Optional[bool] Whether the edges file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash. edge_list_max_rows_number: Optional[int] The maximum number of lines to be loaded from the edges file. edge_list_comment_symbol: Optional[str] The comment symbol to skip lines in the edges file. Lines starting with this symbol will be skipped. edges_number: Optional[int] The expected number of edges. Note that this must be the EXACT number of edges in the graph. load_edge_list_in_parallel: Optional[bool] Whether to load the edge list in parallel. Note that, if the edge IDs indices are not given, it is NOT possible to load a sorted edge list. Similarly, when loading in parallel, without edge IDs, the edges may not be loaded in a deterministic order. verbose: Optional[bool] Whether to show a loading bar while reading the files. Note that, if parallel loading is enabled, loading bars will not be showed because they are a synchronization bottleneck. may_have_singletons: Optional[bool] Whether the graph may be expected to have singleton nodes. If it is said that it surely DOES NOT have any, it will allow for some speedups and lower mempry peaks. may_have_singleton_with_selfloops: Optional[bool] Whether the graph may be expected to have singleton nodes with selfloops. If it is said that it surely DOES NOT have any, it will allow for some speedups and lower mempry peaks. directed: bool Whether to load the graph as directed or undirected. name: Optional[str] The name of the graph to be loaded.""" pass def get_connected_components_number(self, verbose: Optional[bool]) -> Tuple[int, int, int]: """Returns number a triple with (number of components, number of nodes of the smallest component, number of nodes of the biggest component ) Parameters ---------- verbose: Optional[bool] Whether to show a loading bar or not.""" pass def get_number_of_connected_nodes(self) -> int: """Returns number of connected nodes in the graph.""" pass def get_singleton_nodes_with_selfloops_number(self) -> int: """Returns number of singleton nodes with selfloops within the graph.""" pass def get_number_of_singleton_nodes(self) -> int: """Returns number of singleton nodes within the graph.""" pass def get_number_of_disconnected_nodes(self) -> int: """Returns number of disconnected nodes within the graph. A Disconnected node is a node which is nor a singleton nor a singleton with selfloops.""" pass def get_singleton_node_ids(self) -> np.ndarray: """Returns vector of singleton node IDs of the graph.""" pass def get_singleton_node_names(self) -> List[str]: """Returns vector of singleton node names of the graph.""" pass def get_singleton_with_selfloops_node_ids(self) -> np.ndarray: """Returns vector of singleton_with_selfloops node IDs of the graph.""" pass def get_singleton_with_selfloops_node_names(self) -> List[str]: """Returns vector of singleton_with_selfloops node names of the graph.""" pass def get_density(self) -> float: """Returns density of the graph.""" pass def get_trap_nodes_rate(self) -> float: """Returns the traps rate of the graph. THIS IS EXPERIMENTAL AND MUST BE PROVEN!""" pass def get_node_degrees_mean(self) -> float: """Returns unweighted mean node degree of the graph.""" pass def get_weighted_node_degrees_mean(self) -> float: """Returns weighted mean node degree of the graph.""" pass def get_undirected_edges_number(self) -> int: """Returns number of undirected edges of the graph.""" pass def get_unique_undirected_edges_number(self) -> int: """Returns number of undirected edges of the graph.""" pass def get_edges_number(self) -> int: """Returns number of edges of the graph.""" pass def get_unique_edges_number(self) -> int: """Returns number of unique edges of the graph.""" pass def get_node_degrees_median(self) -> int: """Returns unweighted median node degree of the graph""" pass def get_weighted_node_degrees_median(self) -> float: """Returns weighted median node degree of the graph""" pass def get_maximum_node_degree(self) -> int: """Returns maximum node degree of the graph. Raises ------- ValueError If the graph does not contain any node (is an empty graph).""" pass def get_unchecked_most_central_node_id(self) -> int: """Returns maximum node degree of the graph. Safety ------ This method fails with a panic if the graph does not have any node.""" pass def get_most_central_node_id(self) -> int: """Returns maximum node degree of the graph.""" pass def get_minimum_node_degree(self) -> int: """Returns minimum node degree of the graph. Raises ------- ValueError If the graph does not contain any node (is an empty graph).""" pass def get_node_degrees_mode(self) -> int: """Returns mode node degree of the graph.""" pass def get_selfloop_nodes_rate(self) -> float: """Returns rate of self-loops.""" pass def get_name(self) -> str: """Return name of the graph.""" pass def get_number_of_trap_nodes(self) -> int: """Return the number of traps (nodes without any outgoing edges that are not singletons) This also includes nodes with only a self-loops, therefore singletons with only a self-loops are not considered traps because you could make a walk on them.""" pass def get_source_node_ids(self, directed: bool) -> np.ndarray: """Return vector of the non-unique source nodes. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass def get_directed_source_node_ids(self) -> np.ndarray: """Return vector on the (non unique) directed source nodes of the graph""" pass def get_source_names(self, directed: bool) -> List[str]: """Return vector of the non-unique source nodes names. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass def get_destination_node_ids(self, directed: bool) -> np.ndarray: """Return vector on the (non unique) destination nodes of the graph. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass def get_directed_destination_node_ids(self) -> np.ndarray: """Return vector on the (non unique) directed destination nodes of the graph""" pass def get_destination_names(self, directed: bool) -> List[str]: """Return vector of the non-unique destination nodes names. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass def get_node_names(self) -> List[str]: """Return vector with the sorted nodes names""" pass def get_node_urls(self) -> List[Optional[str]]: """Return vector with the node URLs.""" pass def get_node_ontologies(self) -> List[Optional[str]]: """Return vector with the node predicted ontology.""" pass def get_node_ids(self) -> np.ndarray: """Return vector with the sorted nodes Ids""" pass def get_edge_type_ids(self) -> List[Optional[int]]: """Return the edge types of the edges""" pass def get_unique_edge_type_ids(self) -> np.ndarray: """Return the unique edge type IDs of the graph edges.""" pass def get_edge_type_names(self) -> List[Optional[str]]: """Return the edge types names""" pass def get_unique_edge_type_names(self) -> List[str]: """Return the edge types names""" pass def get_edge_weights(self) -> np.ndarray: """Return the weights of the graph edges.""" pass def get_weighted_node_indegrees(self) -> np.ndarray: """Return the weighted indegree (total weighted inbound edge weights) for each node.""" pass def get_node_type_ids(self) -> List[Optional[List[int]]]: """Return the node types of the graph nodes.""" pass def get_known_node_types_mask(self) -> np.ndarray: """Returns boolean mask of known node types. Raises ------- ValueError If the graph does not have node types.""" pass def get_unknown_node_types_mask(self) -> np.ndarray: """Returns boolean mask of unknown node types. Raises ------- ValueError If the graph does not have node types.""" pass def get_one_hot_encoded_node_types(self) -> np.ndarray: """Returns one-hot encoded node types. Raises ------- ValueError If the graph does not have node types.""" pass def get_one_hot_encoded_known_node_types(self) -> np.ndarray: """Returns one-hot encoded known node types. Raises ------- ValueError If the graph does not have node types.""" pass def get_one_hot_encoded_edge_types(self) -> np.ndarray: """Returns one-hot encoded edge types. Raises ------- ValueError If the graph does not have edge types.""" pass def get_one_hot_encoded_known_edge_types(self) -> np.ndarray: """Returns one-hot encoded known edge types. Raises ------- ValueError If the graph does not have edge types.""" pass def get_node_type_names(self) -> List[Optional[List[str]]]: """Return the node types names.""" pass def get_unique_node_type_ids(self) -> np.ndarray: """Return the unique node type IDs of the graph nodes.""" pass def get_unique_node_type_names(self) -> List[str]: """Return the unique node types names.""" pass def get_unique_directed_edges_number(self) -> int: """Return number of the unique edges in the graph""" pass def get_nodes_mapping(self) -> Dict[str, int]: """Return the nodes mapping""" pass def get_edge_node_ids(self, directed: bool) -> np.ndarray: """Return vector with the sorted edge Ids. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass def get_directed_edge_node_ids(self) -> np.ndarray: """Return vector with the sorted directed edge Ids""" pass def get_edge_node_names(self, directed: bool) -> List[Tuple[str, str]]: """Return vector with the sorted edge names. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass def get_directed_edge_node_names(self) -> List[Tuple[str, str]]: """Return vector with the sorted directed edge names""" pass def get_unknown_node_types_number(self) -> int: """Returns number of nodes with unknown node type. Raises ------- ValueError If there are no node types in the graph.""" pass def get_known_node_types_number(self) -> int: """Returns the number of node with known node type. Raises ------- ValueError If there are no node types in the graph.""" pass def get_unknown_node_types_rate(self) -> float: """Returns rate of unknown node types over total nodes number. Raises ------- ValueError If there are no node types in the graph.""" pass def get_known_node_types_rate(self) -> float: """Returns rate of known node types over total nodes number. Raises ------- ValueError If there are no node types in the graph.""" pass def get_minimum_node_types_number(self) -> int: """Returns minimum number of node types. Raises ------- ValueError If there are no node types in the graph.""" pass def get_maximum_node_types_number(self) -> int: """Returns maximum number of node types. Raises ------- ValueError If there are no node types in the graph.""" pass def get_maximum_multilabel_count(self) -> int: """Returns number of maximum multilabel count. This value is the maximum number of multilabel counts that appear in any given node in the graph""" pass def get_singleton_node_types_number(self) -> int: """Returns number of singleton node types. Raises ------- ValueError If the graph does not have node types.""" pass def get_singleton_node_type_ids(self) -> np.ndarray: """Returns vector of singleton node types IDs. Raises ------- ValueError If the graph does not have node types.""" pass def get_singleton_node_type_names(self) -> List[str]: """Returns vector of singleton node types names. Raises ------- ValueError If the graph does not have node types.""" pass def get_unknown_edge_types_number(self) -> int: """Returns number of unknown edge types. Raises ------- ValueError If there are no edge types in the graph.""" pass def get_edge_ids_with_unknown_edge_types(self) -> np.ndarray: """Returns edge IDs of the edges with unknown edge types Raises ------- ValueError If there are no edge types in the graph.""" pass def get_edge_ids_with_known_edge_types(self) -> np.ndarray: """Returns edge IDs of the edges with known edge types Raises ------- ValueError If there are no edge types in the graph.""" pass def get_edge_node_ids_with_unknown_edge_types(self, directed: bool) -> List[Tuple[int, int]]: """Returns edge node IDs of the edges with unknown edge types Parameters ---------- directed: bool Whether to iterated the edges as a directed or undirected edge list. Raises ------- ValueError If there are no edge types in the graph.""" pass def get_edge_node_ids_with_known_edge_types(self, directed: bool) -> List[Tuple[int, int]]: """Returns edge node IDs of the edges with known edge types Parameters ---------- directed: bool Whether to iterated the edges as a directed or undirected edge list. Raises ------- ValueError If there are no edge types in the graph.""" pass def get_edge_node_names_with_unknown_edge_types(self, directed: bool) -> List[Tuple[str, str]]: """Returns edge node names of the edges with unknown edge types Parameters ---------- directed: bool Whether to iterated the edges as a directed or undirected edge list. Raises ------- ValueError If there are no edge types in the graph.""" pass def get_edge_node_names_with_known_edge_types(self, directed: bool) -> List[Tuple[str, str]]: """Returns edge node names of the edges with known edge types Parameters ---------- directed: bool Whether to iterated the edges as a directed or undirected edge list. Raises ------- ValueError If there are no edge types in the graph.""" pass def get_edge_ids_with_unknown_edge_types_mask(self) -> np.ndarray: """Returns a boolean vector that for each node contains whether it has an unknown node type. Raises ------- ValueError If there are no edge types in the graph.""" pass def get_edge_ids_with_known_edge_types_mask(self) -> np.ndarray: """Returns a boolean vector that for each node contains whether it has an unknown edge type. Raises ------- ValueError If there are no edge types in the graph.""" pass def get_node_ids_with_unknown_node_types(self) -> np.ndarray: """Returns node IDs of the nodes with unknown node types Raises ------- ValueError If there are no node types in the graph.""" pass def get_node_ids_with_known_node_types(self) -> np.ndarray: """Returns node IDs of the nodes with known node types Raises ------- ValueError If there are no node types in the graph.""" pass def get_node_names_with_unknown_node_types(self) -> List[str]: """Returns node names of the nodes with unknown node types Raises ------- ValueError If there are no node types in the graph.""" pass def get_node_names_with_known_node_types(self) -> List[str]: """Returns node names of the nodes with known node types Raises ------- ValueError If there are no node types in the graph.""" pass def get_node_ids_with_unknown_node_types_mask(self) -> np.ndarray: """Returns a boolean vector that for each node contains whether it has an unknown node type. Raises ------- ValueError If there are no node types in the graph.""" pass def get_node_ids_with_known_node_types_mask(self) -> np.ndarray: """Returns a boolean vector that for each node contains whether it has an known node type. Raises ------- ValueError If there are no node types in the graph.""" pass def get_known_edge_types_number(self) -> int: """Returns the number of edge with known edge type. Raises ------- ValueError If there are no edge types in the graph.""" pass def get_unknown_edge_types_rate(self) -> float: """Returns rate of unknown edge types over total edges number. Raises ------- ValueError If there are no edge types in the graph.""" pass def get_known_edge_types_rate(self) -> float: """Returns rate of known edge types over total edges number. Raises ------- ValueError If there are no edge types in the graph.""" pass def get_minimum_edge_types_number(self) -> int: """Returns minimum number of edge types. Raises ------- ValueError If there are no edge types in the graph.""" pass def get_singleton_edge_types_number(self) -> int: """Returns number of singleton edge types. Raises ------- ValueError If the graph does not have edge types.""" pass def get_singleton_edge_type_ids(self) -> np.ndarray: """Returns vector of singleton edge types IDs. Raises ------- ValueError If the graph does not have edge types.""" pass def get_singleton_edge_type_names(self) -> List[str]: """Returns vector of singleton edge types names. Raises ------- ValueError If the graph does not have edge types.""" pass def get_number_of_nodes(self) -> int: """Returns number of nodes in the graph""" pass def get_node_connected_component_ids(self, verbose: Optional[bool]) -> np.ndarray: """Return a vector with the components each node belongs to. E.g. If we have two components `[0, 2, 3]` and `[1, 4, 5]` the result will look like `[0, 1, 0, 0, 1, 1]` Parameters ---------- verbose: Optional[bool] Whether to show the loading bar.""" pass def get_directed_edges_number(self) -> int: """Returns number of directed edges in the graph""" pass def get_edge_types_number(self) -> int: """Returns number of edge types in the graph. Raises ------- ValueError If there are no edge types in the current graph.""" pass def get_node_types_number(self) -> int: """Returns number of node types in the graph. Raises ------- ValueError If there are no node types in the current graph.""" pass def get_node_degrees(self) -> np.ndarray: """Returns the unweighted degree of every node in the graph""" pass def get_node_indegrees(self) -> np.ndarray: """Return the indegree for each node.""" pass def get_weighted_node_degrees(self) -> np.ndarray: """Returns the weighted degree of every node in the graph""" pass def get_not_singletons_node_ids(self) -> np.ndarray: """Return set of nodes that are not singletons""" pass def get_dense_nodes_mapping(self) -> Dict[int, int]: """Return mapping from instance not trap nodes to dense nodes""" pass def get_parallel_edges_number(self) -> int: """Return number of edges that have multigraph syblings""" pass def get_cumulative_node_degrees(self) -> np.ndarray: """Return vector with node cumulative_node_degrees, that is the comulative node degree""" pass def get_reciprocal_sqrt_degrees(self) -> np.ndarray: """Return vector wit""" pass def get_number_of_unique_source_nodes(self) -> int: """Returns number of the source nodes.""" pass def get_edge_type_id_counts_hashmap(self) -> Dict[int, int]: """Returns edge type IDs counts hashmap. Raises ------- ValueError If there are no edge types in the current graph instance.""" pass def get_edge_type_names_counts_hashmap(self) -> Dict[str, int]: """Returns edge type names counts hashmap. Raises ------- ValueError If there are no edge types in the current graph instance.""" pass def get_node_type_id_counts_hashmap(self) -> Dict[int, int]: """Returns node type IDs counts hashmap. Raises ------- ValueError If there are no node types in the current graph instance.""" pass def get_node_type_names_counts_hashmap(self) -> Dict[str, int]: """Returns node type names counts hashmap. Raises ------- ValueError If there are no node types in the current graph instance.""" pass def has_default_graph_name(self) -> bool: """Return if graph has name that is not the default one. TODO: use a default for the default graph name""" pass def has_nodes(self) -> bool: """Return if the graph has any nodes.""" pass def has_edges(self) -> bool: """Return if the graph has any edges.""" pass def has_trap_nodes(self) -> bool: """Return whether the graph has trap nodes.""" pass def is_directed(self) -> bool: """Returns boolean representing if graph is directed.""" pass def has_edge_weights(self) -> bool: """Returns boolean representing whether graph has weights.""" pass def has_edge_weights_representing_probabilities(self) -> bool: """Returns whether graph has weights that can represent probabilities""" pass def has_weighted_singleton_nodes(self) -> bool: """Returns whether a graph has one or more weighted singleton nodes. A weighted singleton node is a node whose weighted node degree is 0. Raises ------- ValueError If the graph does not contain edge weights.""" pass def has_constant_edge_weights(self) -> bool: """Returns whether the graph has constant weights. Raises ------- ValueError If the graph does not contain edge weights.""" pass def has_negative_edge_weights(self) -> bool: """Returns boolean representing whether graph has negative weights. Raises ------- ValueError If the graph does not contain weights.""" pass def has_edge_types(self) -> bool: """Returns boolean representing whether graph has edge types.""" pass def has_selfloops(self) -> bool: """Returns boolean representing if graph has self-loops.""" pass def has_disconnected_nodes(self) -> bool: """Returns boolean representing if nodes which are nor singletons nor singletons with selfloops.""" pass def has_singleton_nodes(self) -> bool: """Returns boolean representing if graph has singletons.""" pass def has_singleton_nodes_with_selfloops(self) -> bool: """Returns boolean representing if graph has singletons""" pass def is_connected(self, verbose: Optional[bool]) -> bool: """Returns whether the graph is connected. Parameters ---------- verbose: Optional[bool] Whether to show the loading bar while computing the connected components, if necessary.""" pass def has_node_types(self) -> bool: """Returns boolean representing if graph has node types""" pass def has_multilabel_node_types(self) -> bool: """Returns boolean representing if graph has multilabel node types. Raises ------- ValueError If the graph does not have node types.""" pass def has_unknown_node_types(self) -> bool: """Returns whether there are unknown node types. Raises ------- ValueError If the graph does not have node types.""" pass def has_known_node_types(self) -> bool: """Returns whether there are known node types. Raises ------- ValueError If the graph does not have node types.""" pass def has_unknown_edge_types(self) -> bool: """Returns whether there are unknown edge types. Raises ------- ValueError If the graph does not have node types.""" pass def has_known_edge_types(self) -> bool: """Returns whether there are known edge types. Raises ------- ValueError If the graph does not have edge types.""" pass def has_homogeneous_node_types(self) -> bool: """Returns whether the nodes have an homogenous node type. Raises ------- ValueError If the graph does not have node types.""" pass def has_homogeneous_edge_types(self) -> bool: """Returns whether the edges have an homogenous edge type. Raises ------- ValueError If the graph does not have edge types.""" pass def has_singleton_node_types(self) -> bool: """Returns whether there is at least singleton node type, that is a node type that only appears once. Raises ------- ValueError If the graph does not have node types.""" pass def has_node_oddities(self) -> bool: """Return whether the graph has any known node-related graph oddities""" pass def has_node_types_oddities(self) -> bool: """Return whether the graph has any known node type-related graph oddities. Raises ------- ValueError If the graph does not have node types.""" pass def has_singleton_edge_types(self) -> bool: """Returns whether there is at least singleton edge type, that is a edge type that only appears once. Raises ------- ValueError If the graph does not have edge types.""" pass def has_edge_types_oddities(self) -> bool: """Return whether the graph has any known edge type-related graph oddities. Raises ------- ValueError If the graph does not have edge types.""" pass def is_multigraph(self) -> bool: """Return if there are multiple edges between two node""" pass def has_nodes_sorted_by_decreasing_outbound_node_degree(self) -> bool: """Returns whether the node IDs are sorted by decreasing outbound node degree.""" pass def has_nodes_sorted_by_lexicographic_order(self) -> bool: """Returns whether the node IDs are sorted by decreasing outbound node degree.""" pass def contains_identity_matrix(self) -> bool: """Returns whether the graph contains the indentity matrix.""" pass def has_nodes_sorted_by_increasing_outbound_node_degree(self) -> bool: """Returns whether the node IDs are sorted by increasing outbound node degree.""" pass def get_total_edge_weights(self) -> float: """Return total edge weights, if graph has weights. Raises ------- ValueError If the graph does not contain edge weights.""" pass def get_mininum_edge_weight(self) -> float: """Return the minimum weight, if graph has weights. Raises ------- ValueError If the graph does not contain edge weights.""" pass def get_maximum_edge_weight(self) -> float: """Return the maximum weight, if graph has weights. Raises ------- ValueError If the graph does not contain edge weights.""" pass def get_unchecked_maximum_node_degree(self) -> int: """Return the maximum node degree. Safety ------ The method will return an undefined value (0) when the graph does not contain nodes. In those cases the value is not properly defined.""" pass def get_unchecked_minimum_node_degree(self) -> int: """Return the minimum node degree. Safety ------ The method will return an undefined value (0) when the graph does not contain nodes. In those cases the value is not properly defined.""" pass def get_weighted_maximum_node_degree(self) -> float: """Return the maximum weighted node degree""" pass def get_weighted_minimum_node_degree(self) -> float: """Return the minimum weighted node degree""" pass def get_number_of_weighted_singleton_nodes(self) -> int: """Return the number of weighted singleton nodes, i.e. nodes with weighted node degree equal to zero""" pass def get_selfloops_number(self) -> int: """Returns number of self-loops, including also those in eventual multi-edges.""" pass def get_unique_selfloops_number(self) -> int: """Returns number of unique self-loops, excluding those in eventual multi-edges.""" pass def overlaps(self, other: Graph) -> bool: """Return whether given graph has any edge overlapping with current graph. Parameters ---------- other: Graph The graph to check against. Raises ------- ValueError If a graph is directed and the other is undirected. ValueError If one of the two graphs has edge weights and the other does not. ValueError If one of the two graphs has node types and the other does not. ValueError If one of the two graphs has edge types and the other does not.""" pass def contains(self, other: Graph) -> bool: """Return true if given graph edges are all contained within current graph. Parameters ---------- other: Graph The graph to check against. Raises ------- ValueError If a graph is directed and the other is undirected. ValueError If one of the two graphs has edge weights and the other does not. ValueError If one of the two graphs has node types and the other does not. ValueError If one of the two graphs has edge types and the other does not.""" pass def sample_negatives(self, negatives_number: int, random_state: Optional[int], seed_graph: Optional[Graph], only_from_same_component: Optional[bool], verbose: Optional[bool]) -> Graph: """Returns Graph with given amount of negative edges as positive edges. The graph generated may be used as a testing negatives partition to be fed into the argument "graph_to_avoid" of the link_prediction or the skipgrams algorithm Parameters ---------- negatives_number: int Number of negatives edges to include. random_state: Optional[int] random_state to use to reproduce negative edge set. seed_graph: Optional[Graph] Optional graph to use to filter the negative edges. The negative edges generated when this variable is provided will always have a node within this graph. only_from_same_component: Optional[bool] Whether to sample negative edges only from nodes that are from the same component. verbose: Optional[bool] Whether to show the loading bar.""" pass def connected_holdout(self, train_size: float, random_state: Optional[int], edge_types: Optional[List[Optional[str]]], include_all_edge_types: Optional[bool], verbose: Optional[bool]) -> Tuple[Graph, Graph]: """Returns holdout for training ML algorithms on the graph structure. The holdouts returned are a tuple of graphs. The first one, which is the training graph, is garanteed to have the same number of graph components as the initial graph. The second graph is the graph meant for testing or validation of the algorithm, and has no garantee to be connected. It will have at most (1-train_size) edges, as the bound of connectivity which is required for the training graph may lead to more edges being left into the training partition. In the option where a list of edge types has been provided, these edge types will be those put into the validation set. Parameters ---------- train_size: float Rate target to reserve for training. random_state: Optional[int] The random_state to use for the holdout, edge_types: Optional[List[Optional[str]]] Edge types to be selected for in the validation set. include_all_edge_types: Optional[bool] Whether to include all the edges between two nodes. verbose: Optional[bool] Whether to show the loading bar. Raises ------- ValueError If the edge types have been specified but the graph does not have edge types. ValueError If the required training size is not a real value between 0 and 1. ValueError If the current graph does not allow for the creation of a spanning tree for the requested training size.""" pass def random_holdout(self, train_size: float, random_state: Optional[int], include_all_edge_types: Optional[bool], edge_types: Optional[List[Optional[str]]], min_number_overlaps: Optional[int], verbose: Optional[bool]) -> Tuple[Graph, Graph]: """Returns random holdout for training ML algorithms on the graph edges. The holdouts returned are a tuple of graphs. In neither holdouts the graph connectivity is necessarily preserved. To maintain that, use the method `connected_holdout`. Parameters ---------- train_size: float rate target to reserve for training random_state: Optional[int] The random_state to use for the holdout, include_all_edge_types: Optional[bool] Whether to include all the edges between two nodes. edge_types: Optional[List[Optional[str]]] The edges to include in validation set. min_number_overlaps: Optional[int] The minimum number of overlaps to include the edge into the validation set. verbose: Optional[bool] Whether to show the loading bar. Raises ------- ValueError If the edge types have been specified but the graph does not have edge types. ValueError If the minimum number of overlaps have been specified but the graph is not a multigraph. ValueError If one or more of the given edge type names is not present in the graph.""" pass def get_node_label_holdout_indices(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[List[int], List[int]]: """Returns node-label holdout indices for training ML algorithms on the graph node labels. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use node-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have node types. ValueError If stratification is requested but the graph has a single node type. ValueError If stratification is requested but the graph has a multilabel node types.""" pass def get_node_label_holdout_labels(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[List[Optional[List[int]]], List[Optional[List[int]]]]: """Returns node-label holdout indices for training ML algorithms on the graph node labels. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use node-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have node types. ValueError If stratification is requested but the graph has a single node type. ValueError If stratification is requested but the graph has a multilabel node types.""" pass def get_node_label_holdout_graphs(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns node-label holdout for training ML algorithms on the graph node labels. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use node-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have node types. ValueError If stratification is requested but the graph has a single node type. ValueError If stratification is requested but the graph has a multilabel node types.""" pass def get_edge_label_holdout_graphs(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns edge-label holdout for training ML algorithms on the graph edge labels. This is commonly used for edge type prediction tasks. This method returns two graphs, the train and the test one. The edges of the graph will be splitted in the train and test graphs according to the `train_size` argument. If stratification is enabled, the train and test will have the same ratios of edge types. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use edge-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have edge types. ValueError If stratification is required but the graph has singleton edge types.""" pass def get_random_subgraph(self, number_of_nodes: int, random_state: Optional[int], verbose: Optional[bool]) -> Graph: """Returns subgraph with given number of nodes. **This method creates a subset of the graph starting from a random node sampled using given random_state and includes all neighbouring nodes until the required number of nodes is reached**. All the edges connecting any of the selected nodes are then inserted into this graph. This is meant to execute distributed node embeddings. It may also sample singleton nodes. Parameters ---------- number_of_nodes: int Number of nodes to extract. random_state: Optional[int] Random random_state to use. verbose: Optional[bool] Whether to show the loading bar. Raises ------- ValueError If the requested number of nodes is one or less. ValueError If the graph has less than the requested number of nodes.""" pass def get_node_label_random_holdout(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns node-label holdout for training ML algorithms on the graph node labels. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use node-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have node types. ValueError If stratification is requested but the graph has a single node type. ValueError If stratification is requested but the graph has a multilabel node types.""" pass def get_node_label_kfold(self, k: int, k_index: int, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns node-label fold for training ML algorithms on the graph node labels. Parameters ---------- k: int The number of folds. k_index: int Which fold to use for the validation. use_stratification: Optional[bool] Whether to use node-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have node types. ValueError If stratification is requested but the graph has a single node type. ValueError If stratification is requested but the graph has a multilabel node types.""" pass def get_edge_label_random_holdout(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns edge-label holdout for training ML algorithms on the graph edge labels. This is commonly used for edge type prediction tasks. This method returns two graphs, the train and the test one. The edges of the graph will be splitted in the train and test graphs according to the `train_size` argument. If stratification is enabled, the train and test will have the same ratios of edge types. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use edge-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have edge types. ValueError If stratification is required but the graph has singleton edge types.""" pass def get_edge_label_kfold(self, k: int, k_index: int, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns edge-label kfold for training ML algorithms on the graph edge labels. This is commonly used for edge type prediction tasks. This method returns two graphs, the train and the test one. The edges of the graph will be splitted in the train and test graphs according to the `train_size` argument. If stratification is enabled, the train and test will have the same ratios of edge types. Parameters ---------- k: int The number of folds. k_index: int Which fold to use for the validation. use_stratification: Optional[bool] Whether to use edge-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have edge types. ValueError If stratification is required but the graph has singleton edge types.""" pass def get_edge_prediction_kfold(self, k: int, k_index: int, edge_types: Optional[List[Optional[str]]], random_state: Optional[int], verbose: Optional[bool]) -> Tuple[Graph, Graph]: """Returns train and test graph following kfold validation scheme. The edges are splitted into k chunks. The k_index-th chunk is used to build the validation graph, all the other edges create the training graph. Parameters ---------- k: int The number of folds. k_index: int Which fold to use for the validation. edge_types: Optional[List[Optional[str]]] Edge types to be selected when computing the folds (All the edge types not listed here will be always be used in the training set). random_state: Optional[int] The random_state (seed) to use for the holdout, verbose: Optional[bool] Whether to show the loading bar. Raises ------- ValueError If the number of requested k folds is one or zero. ValueError If the given k fold index is greater than the number of k folds. ValueError If edge types have been specified but it's an empty list. ValueError If the number of k folds is higher than the number of edges in the graph.""" pass def get_laplacian_transformed_graph(self) -> Graph: """Returns unweighted laplacian transformation of the graph""" pass def get_laplacian_coo_matrix_edges_number(self) -> int: """Returns number of edges in the laplacian COO matrix representation of the graph""" pass def get_random_walk_normalized_laplacian_transformed_graph(self) -> Graph: """Returns unweighted random walk normalized laplacian transformation of the graph""" pass def get_symmetric_normalized_laplacian_transformed_graph(self) -> Graph: """Returns unweighted symmetric normalized laplacian transformation of the graph. Raises ------- ValueError The graph must be undirected, as we do not currently support this transformation for directed graphs.""" pass def get_symmetric_normalized_transformed_graph(self) -> Graph: """Returns unweighted symmetric normalized transformation of the graph. Raises ------- ValueError The graph must be undirected, as we do not currently support this transformation for directed graphs.""" pass def get_undirected_louvain_community_detection(self, recursion_minimum_improvement: Optional[float], first_phase_minimum_improvement: Optional[float], patience: Optional[int], random_state: Optional[int]) -> List[List[int]]: """Returns vector of vectors of communities for each layer of hierarchy minimizing undirected modularity. Parameters ---------- recursion_minimum_improvement: Optional[float] The minimum improvement to warrant another resursion round. By default, zero. first_phase_minimum_improvement: Optional[float] The minimum improvement to warrant another first phase iteration. By default, `0.00001` (not zero because of numerical instability). patience: Optional[int] How many iterations of the first phase to wait for before stopping. By default, `5`. random_state: Optional[int] The random state to use to reproduce this modularity computation. By default, 42. Raises ------- ValueError If the graph is not directed. ValueError If the `recursion_minimum_improvement` has an invalid value, i.e. NaN or infinity. ValueError If the `first_phase_minimum_improvement` has an invalid value, i.e. NaN or infinity.""" pass def get_directed_modularity_from_node_community_memberships(self, node_community_memberships: List[int]) -> float: """Returns the directed modularity of the graph from the given memberships. Parameters ---------- Raises ------- ValueError If the number of provided memberships does not match the number of nodes of the graph.""" pass def get_undirected_modularity_from_node_community_memberships(self, node_community_memberships: List[int]) -> float: """Returns the undirected modularity of the graph from the given memberships. Parameters ---------- Raises ------- ValueError If the number of provided memberships does not match the number of nodes of the graph.""" pass def get_memory_stats(self) -> str: """Returns a string describing the memory usage of all the fields of all the structures used to store the current graph""" pass def get_total_memory_used(self) -> int: """Returns how many bytes are currently used to store the given graph""" pass def get_nodes_total_memory_requirement(self) -> int: """Returns how many bytes are currently used to store the nodes""" pass def get_nodes_total_memory_requirement_human_readable(self) -> str: """Returns human readable amount of how many bytes are currently used to store the nodes""" pass def get_edges_total_memory_requirement(self) -> int: """Returns how many bytes are currently used to store the edges""" pass def get_edges_total_memory_requirement_human_readable(self) -> str: """Returns human readable amount of how many bytes are currently used to store the edges""" pass def get_edge_weights_total_memory_requirements(self) -> int: """Returns how many bytes are currently used to store the edge weights""" pass def get_edge_weights_total_memory_requirements_human_readable(self) -> str: """Returns human readable amount of how many bytes are currently used to store the edge weights""" pass def get_node_types_total_memory_requirements(self) -> int: """Returns how many bytes are currently used to store the node types""" pass def get_node_types_total_memory_requirements_human_readable(self) -> str: """Returns human readable amount of how many bytes are currently used to store the node types""" pass def get_edge_types_total_memory_requirements(self) -> int: """Returns how many bytes are currently used to store the edge types""" pass def get_edge_types_total_memory_requirements_human_readable(self) -> str: """Returns human readable amount of how many bytes are currently used to store the edge types""" pass def enable(self, vector_sources: Optional[bool], vector_destinations: Optional[bool], vector_cumulative_node_degrees: Optional[bool], vector_reciprocal_sqrt_degrees: Optional[bool]): """Enable extra perks that buys you time as you accept to spend more memory. Parameters ---------- vector_sources: Optional[bool] Whether to cache sources into a vector for faster walks. vector_destinations: Optional[bool] Whether to cache destinations into a vector for faster walks. vector_cumulative_node_degrees: Optional[bool] Whether to cache cumulative_node_degrees into a vector for faster walks. vector_reciprocal_sqrt_degrees: Optional[bool] Whether to cache reciprocal_sqrt_degrees into a vector for faster laplacian kernel computation.""" pass def get_random_nodes(self, number_of_nodes_to_sample: int, random_state: int) -> np.ndarray: """Return random unique sorted numbers. Parameters ---------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to use to reproduce the sampling.""" pass def get_breadth_first_search_random_nodes(self, number_of_nodes_to_sample: int, root_node: int) -> np.ndarray: """Return nodes sampled from the neighbourhood of given root nodes. Parameters ---------- number_of_nodes_to_sample: int The number of nodes to sample. root_node: int The root node from . Raises ------- ValueError If the number of requested nodes is higher than the number of nodes in the graph. ValueError If the given root node does not exist in the curret graph instance.""" pass def get_uniform_random_walk_random_nodes(self, node: int, random_state: int, walk_length: int, unique: Optional[bool]) -> np.ndarray: """Returns unique nodes sampled from uniform random walk. Parameters ---------- node: int Node from where to start the random walks. random_state: int the random_state to use for extracting the nodes and edges. walk_length: int Length of the random walk. unique: Optional[bool] Whether to make the sampled nodes unique. Raises ------- ValueError If the given node does not exist in the current slack.""" pass def get_node_sampling_methods(self) -> List[str]: """Return list of the supported node sampling methods""" pass def get_subsampled_nodes(self, number_of_nodes_to_sample: int, random_state: int, root_node: Optional[int], node_sampling_method: str, unique: Optional[bool]) -> np.ndarray: """Return subsampled nodes according to the given method and parameters. Parameters ---------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to reproduce the sampling. root_node: Optional[int] The (optional) root node to use to sample. In not provided, a random one is sampled. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. unique: Optional[bool] Whether to make the sampled nodes unique. Raises ------- ValueError If the given node sampling method is not supported.""" pass def is_compatible(self, other: Graph) -> bool: """Return true if the graphs are compatible. Parameters ---------- other: Graph The other graph. Raises ------- ValueError If a graph is directed and the other is undirected. ValueError If one of the two graphs has edge weights and the other does not. ValueError If one of the two graphs has node types and the other does not. ValueError If one of the two graphs has edge types and the other does not.""" pass def has_same_adjacency_matrix(self, other: Graph) -> bool: """Return true if the graphs share the same adjacency matrix. Parameters ---------- other: Graph The other graph.""" pass def validate_node_id(self, node_id: int) -> int: """Validates provided node ID. Parameters ---------- node_id: int node ID to validate. Raises ------- ValueError If the given node ID does not exists in the graph.""" pass def validate_node_ids(self, node_ids: List[int]) -> np.ndarray: """Validates all provided node IDs. Parameters ---------- node_ids: List[int] node IDs to validate. Raises ------- ValueError If any of the given node ID does not exists in the graph.""" pass def validate_edge_id(self, edge_id: int) -> int: """Validates provided edge ID. Parameters ---------- edge_id: int Edge ID to validate. Raises ------- ValueError If the given edge ID does not exists in the graph.""" pass def validate_edge_ids(self, edge_ids: List[int]) -> np.ndarray: """Validates provided edge IDs. Parameters ---------- edge_ids: List[int] Edge IDs to validate. Raises ------- ValueError If any of the given edge ID does not exists in the graph.""" pass def must_not_contain_unknown_node_types(self): """Raises an error if the graph contains unknown node types. Raises ------- ValueError If the graph does not contain node types. ValueError If the graph contains unknown node types.""" pass def must_not_contain_unknown_edge_types(self): """Raises an error if the graph contains unknown edge types. Raises ------- ValueError If the graph does not contain edge types. ValueError If the graph contains unknown edge types.""" pass def validate_node_type_id(self, node_type_id: Optional[int]) -> Optional[int]: """Validates provided node type ID. Parameters ---------- node_type_id: Optional[int] Node type ID to validate. Raises ------- ValueError If the given node type ID does not exists in the graph.""" pass def validate_node_type_ids(self, node_type_ids: List[Optional[int]]) -> List[Optional[int]]: """Validates provided node type IDs. Parameters ---------- node_type_ids: List[Optional[int]] Vector of node type IDs to validate. Raises ------- ValueError If there are no node types in the graph.""" pass def validate_edge_type_id(self, edge_type_id: Optional[int]) -> Optional[int]: """Validates provided edge type ID. Parameters ---------- edge_type_id: Optional[int] edge type ID to validate. Raises ------- ValueError If the given edge type ID does not exists in the graph.""" pass def validate_edge_type_ids(self, edge_type_ids: List[Optional[int]]) -> List[Optional[int]]: """Validates provided edge type IDs. Parameters ---------- edge_type_ids: List[Optional[int]] Vector of edge type IDs to validate. Raises ------- ValueError If there are no edge types in the graph.""" pass def must_be_undirected(self): """Raises an error if the graph does not have edge types. Raises ------- ValueError If the graph is directed.""" pass def must_be_multigraph(self): """Raises an error if the graph does not have edge types. Raises ------- ValueError If the graph is not a multigraph.""" pass def must_not_be_multigraph(self): """Raises an error if the graph does not have edge types. Raises ------- ValueError If the graph is a multigraph.""" pass def must_contain_identity_matrix(self): """Raises an error if the graph does not include the identity matrix. Raises ------- ValueError If the graph is a multigraph.""" pass def must_not_contain_weighted_singleton_nodes(self): """Raises an error if the graph contains zero weighted degree. Raises ------- ValueError If the graph does not have edges.""" pass def must_have_edges(self): """Raises an error if the graph has a maximal weighted Raises ------- ValueError If the graph does not have edges.""" pass def must_have_nodes(self): """Raises an error if the graph does not have any node. Raises ------- ValueError If the graph does not have nodes.""" pass def must_be_connected(self): """Raises an error if the graph is not connected. Raises ------- ValueError If the graph is not connected.""" pass def get_number_of_triangles(self, normalize: Optional[bool], low_centrality: Optional[int], verbose: Optional[bool]) -> int: """Returns total number of triangles ignoring the weights. The method dispatches the fastest method according to the current graph instance. Specifically: - For directed graphs it will use the naive algorithm. - For undirected graphs it will use Bader's version. Parameters ---------- normalize: Optional[bool] Whether to normalize the number of triangles. low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass def get_triads_number(self) -> int: """Returns total number of triads in the graph without taking into account weights""" pass def get_weighted_triads_number(self) -> float: """Returns total number of triads in the weighted graph""" pass def get_transitivity(self, low_centrality: Optional[int], verbose: Optional[bool]) -> float: """Returns transitivity of the graph without taking into account weights. Parameters ---------- low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass def get_number_of_triangles_per_node(self, normalize: Optional[bool], low_centrality: Optional[int], verbose: Optional[bool]) -> np.ndarray: """Returns number of triangles in the graph without taking into account the weights. The method dispatches the fastest method according to the current graph instance. Specifically: - For directed graphs it will use the naive algorithm. - For undirected graphs it will use Bader's version. Parameters ---------- normalize: Optional[bool] Whether to normalize the number of triangles. low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass def get_clustering_coefficient_per_node(self, low_centrality: Optional[int], verbose: Optional[bool]) -> np.ndarray: """Returns clustering coefficients for all nodes in the graph. Parameters ---------- low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass def get_clustering_coefficient(self, low_centrality: Optional[int], verbose: Optional[bool]) -> float: """Returns the graph clustering coefficient. Parameters ---------- low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass def get_average_clustering_coefficient(self, low_centrality: Optional[int], verbose: Optional[bool]) -> float: """Returns the graph average clustering coefficient. Parameters ---------- low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass def get_okapi_bm25_node_feature_propagation(self, features: List[List[float]], iterations: Optional[int], maximal_distance: Optional[int], k1: Optional[float], b: Optional[float], include_central_node: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Returns okapi node features propagation within given maximal distance. Parameters ---------- features: List[Optional[List[float]]] The features to propagate. Use None to represent eventual unknown features. iterations: Optional[int] The number of iterations to execute. By default one. maximal_distance: Optional[int] The distance to consider for the cooccurrences. The default value is 3. k1: Optional[float] The k1 parameter from okapi. Tipicaly between 1.2 and 2.0. It can be seen as a smoothing. b: Optional[float] The b parameter from okapi. Tipicaly 0.75. include_central_node: Optional[bool] Whether to include the central node. By default true. verbose: Optional[bool] Whether to show loading bar. Raises ------- ValueError If the graph does not have node types.""" pass def get_okapi_bm25_node_label_propagation(self, iterations: Optional[int], maximal_distance: Optional[int], k1: Optional[float], b: Optional[float], verbose: Optional[bool]) -> np.ndarray: """Returns okapi node label propagation within given maximal distance. Parameters ---------- iterations: Optional[int] The number of iterations to execute. By default one. maximal_distance: Optional[int] The distance to consider for the cooccurrences. The default value is 3. k1: Optional[float] The k1 parameter from okapi. Tipicaly between 1.2 and 2.0. It can be seen as a smoothing. b: Optional[float] The b parameter from okapi. Tipicaly 0.75. verbose: Optional[bool] Whether to show loading bar. Raises ------- ValueError If the graph does not have node types.""" pass def get_unchecked_edge_weight_from_edge_id(self, edge_id: int) -> Optional[float]: """Returns option with the weight of the given edge id. This method will raise a panic if the given edge ID is higher than the number of edges in the graph. Additionally, it will simply return None if there are no graph weights. Parameters ---------- edge_id: int The edge whose edge weight is to be returned. Safety ------ If the given edge ID does not exists in the graph this method will panic.""" pass def get_unchecked_edge_weight_from_node_ids(self, src: int, dst: int) -> float: """Returns option with the weight of the given node ids. This method will raise a panic if the given node IDs are higher than the number of nodes in the graph. Parameters ---------- src: int The source node ID. dst: int The destination node ID. Safety ------ If either of the two given node IDs does not exists in the graph.""" pass def get_unchecked_node_id_from_node_name(self, node_name: str) -> int: """Returns node id from given node name raising a panic if used unproperly. Parameters ---------- node_name: str The node name whose node ID is to be returned. Safety ------ If the given node name does not exists in the considered graph the method will panic.""" pass def get_unchecked_edge_type_id_from_edge_type_name(self, edge_type_name: str) -> Optional[int]: """Return edge type ID corresponding to the given edge type name. Parameters ---------- edge_type_name: str The edge type name whose edge type ID is to be returned. Safety ------ If the given edge type name does not exists in the considered graph the method will panic.""" pass def get_unchecked_edge_type_name_from_edge_type_id(self, edge_type_id: Optional[int]) -> Optional[str]: """Return edge type ID corresponding to the given edge type name raising panic if edge type ID does not exists in current graph. Parameters ---------- edge_type_id: Optional[int] The edge type naIDme whose edge type name is to be returned. Safety ------ If the given edge type ID does not exist in the graph the method will panic.""" pass def get_unchecked_edge_count_from_edge_type_id(self, edge_type: Optional[int]) -> int: """Return number of edges of the given edge type without checks. Parameters ---------- edge_type: Optional[int] The edge type to retrieve count of. Safety ------ If the given edge type ID does not exist in the graph the method will panic.""" pass def get_unchecked_edge_id_from_node_ids_and_edge_type_id(self, src: int, dst: int, edge_type: Optional[int]) -> int: """Return edge ID without any checks for given tuple of nodes and edge type. Parameters ---------- src: int Source node of the edge. dst: int Destination node of the edge. edge_type: Optional[int] Edge Type of the edge. Safety ------ If the given node IDs or edge type does not exists in the graph this method will panic.""" pass def get_unchecked_minmax_edge_ids_from_node_ids(self, src: int, dst: int) -> Tuple[int, int]: """Return range of outbound edges IDs for all the edges bewteen the given source and destination nodes. This operation is meaningfull only in a multigraph. Parameters ---------- src: int Source node. dst: int Destination node. Safety ------ If the given node type IDs do not exist in the graph this method will panic.""" pass def get_unchecked_node_ids_from_edge_id(self, edge_id: int) -> Tuple[int, int]: """Returns node IDs corresponding to given edge ID. The method will panic if the given edge ID does not exists in the current graph instance. Parameters ---------- edge_id: int The edge ID whose source and destination node IDs are to e retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass def get_unchecked_node_names_from_edge_id(self, edge_id: int) -> Tuple[str, str]: """Returns node names corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source and destination node IDs are to e retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass def get_unchecked_source_node_id_from_edge_id(self, edge_id: int) -> int: """Returns the source of given edge id without making any boundary check. Parameters ---------- edge_id: int The edge ID whose source is to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will cause an out of bounds.""" pass def get_unchecked_destination_node_id_from_edge_id(self, edge_id: int) -> int: """Returns the destination of given edge id without making any boundary check. Parameters ---------- edge_id: int The edge ID whose destination is to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will cause an out of bounds.""" pass def get_source_node_id_from_edge_id(self, edge_id: int) -> int: """Returns source node ID corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source node ID is to be retrieved. Raises ------- ValueError If the given edge ID does not exist in the current graph.""" pass def get_destination_node_id_from_edge_id(self, edge_id: int) -> int: """Returns destination node ID corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose destination node ID is to be retrieved. Raises ------- ValueError If the given edge ID does not exist in the current graph.""" pass def get_unchecked_source_node_name_from_edge_id(self, edge_id: int) -> str: """Returns source node name corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source node name is to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass def get_unchecked_destination_node_name_from_edge_id(self, edge_id: int) -> str: """Returns destination node name corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose destination node name is to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass def get_source_node_name_from_edge_id(self, edge_id: int) -> str: """Returns source node name corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source node name is to be retrieved. Raises -------""" pass def get_destination_node_name_from_edge_id(self, edge_id: int) -> str: """Returns destination node name corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose destination node name is to be retrieved. Raises -------""" pass def get_node_names_from_edge_id(self, edge_id: int) -> Tuple[str, str]: """Returns node names corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source and destination node IDs are to e retrieved.""" pass def get_node_ids_from_edge_id(self, edge_id: int) -> Tuple[int, int]: """Returns node names corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source and destination node IDs are to e retrieved.""" pass def get_unchecked_edge_id_from_node_ids(self, src: int, dst: int) -> int: """Returns edge ID corresponding to given source and destination node IDs. The method will panic if the given source and destination node IDs do not correspond to an edge in this graph instance. Parameters ---------- src: int The source node ID. dst: int The destination node ID. Safety ------ If any of the given node IDs do not exist in the graph the method will panic.""" pass def get_edge_id_from_node_ids(self, src: int, dst: int) -> int: """Returns edge ID corresponding to given source and destination node IDs. Parameters ---------- src: int The source node ID. dst: int The destination node ID.""" pass def get_unchecked_unique_source_node_id(self, source_id: int) -> int: """Returns edge ID corresponding to given source and destination node IDs. Parameters ---------- source_id: int The source node ID. Safety ------ If the given source node ID does not exist in the current graph the method will panic.""" pass def get_unchecked_node_ids_and_edge_type_id_from_edge_id(self, edge_id: int) -> Tuple[int, int, Optional[int]]: """Return the src, dst, edge type of a given edge ID. This method will raise a panic when an improper configuration is used. Parameters ---------- edge_id: int The edge ID whose source, destination and edge type are to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass def get_node_ids_and_edge_type_id_from_edge_id(self, edge_id: int) -> Tuple[int, int, Optional[int]]: """Return the src, dst, edge type of a given edge ID. Parameters ---------- edge_id: int The edge ID whose source, destination and edge type are to be retrieved.""" pass def get_unchecked_node_ids_and_edge_type_id_and_edge_weight_from_edge_id(self, edge_id: int) -> Tuple[int, int, Optional[int], Optional[float]]: """Return the src, dst, edge type and weight of a given edge ID. This method will raise a panic when an improper configuration is used. Parameters ---------- edge_id: int The edge ID whose source, destination, edge type and weight are to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass def get_node_ids_and_edge_type_id_and_edge_weight_from_edge_id(self, edge_id: int) -> Tuple[int, int, Optional[int], Optional[float]]: """Return the src, dst, edge type and weight of a given edge ID. Parameters ---------- edge_id: int The edge ID whose source, destination, edge type and weight are to be retrieved.""" pass def get_top_k_central_node_ids(self, k: int) -> np.ndarray: """Return vector with unweighted top k central node Ids. If the k passed is bigger than the number of nodes this method will return all the nodes in the graph. Parameters ---------- k: int Number of central nodes to extract. Raises ------- ValueError If the given value k is zero. ValueError If the graph has no nodes.""" pass def get_weighted_top_k_central_node_ids(self, k: int) -> np.ndarray: """Return vector with weighted top k central node Ids. If the k passed is bigger than the number of nodes this method will return all the nodes in the graph. Parameters ---------- k: int Number of central nodes to extract. Raises ------- ValueError If the current graph instance does not contain edge weights. ValueError If the given value k is zero.""" pass def get_unchecked_node_degree_from_node_id(self, node_id: int) -> int: """Returns the number of outbound neighbours of given node. Parameters ---------- node_id: int Integer ID of the node. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass def get_unchecked_weighted_node_degree_from_node_id(self, node_id: int) -> float: """Returns the weighted sum of outbound neighbours of given node. The method will panic if the given node id is higher than the number of nodes in the graph. Parameters ---------- node_id: int Integer ID of the node. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass def get_node_degree_from_node_id(self, node_id: int) -> int: """Returns the number of outbound neighbours of given node ID. Parameters ---------- node_id: int Integer ID of the node.""" pass def get_unchecked_comulative_node_degree_from_node_id(self, node_id: int) -> int: """Returns the comulative node degree up to the given node. Parameters ---------- node_id: int Integer ID of the node. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass def get_comulative_node_degree_from_node_id(self, node_id: int) -> int: """Returns the comulative node degree up to the given node. Parameters ---------- node_id: int Integer ID of the node.""" pass def get_unchecked_reciprocal_sqrt_degree_from_node_id(self, node_id: int) -> float: """Returns the reciprocal squared root node degree up to the given node. Parameters ---------- node_id: int Integer ID of the node. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass def get_reciprocal_sqrt_degree_from_node_id(self, node_id: int) -> float: """Returns the reciprocal squared root node degree up to the given node. Parameters ---------- node_id: int Integer ID of the node.""" pass def get_unchecked_reciprocal_sqrt_degrees_from_node_ids(self, node_ids: List[int]) -> np.ndarray: """Return vector with reciprocal squared root degree of the provided nodes. Parameters ---------- node_ids: List[int] The vector of node IDs whose reciprocal squared root degree is to be retrieved. Safety ------ This method makes the assumption that the provided node IDs exist in the graph, that is they are not higher than the number of nodes in the graph.""" pass def get_weighted_node_degree_from_node_id(self, node_id: int) -> float: """Returns the weighted sum of outbound neighbours of given node ID. Parameters ---------- node_id: int Integer ID of the node.""" pass def get_node_degree_from_node_name(self, node_name: str) -> int: """Returns the number of outbound neighbours of given node name. Parameters ---------- node_name: str Integer ID of the node. Raises ------- ValueError If the given node name does not exist in the graph.""" pass def get_top_k_central_node_names(self, k: int) -> List[str]: """Return vector with top k central node names. Parameters ---------- k: int Number of central nodes to extract.""" pass def get_unchecked_node_type_id_from_node_id(self, node_id: int) -> Optional[List[int]]: """Returns option with vector of node types of given node. This method will panic if the given node ID is greater than the number of nodes in the graph. Furthermore, if the graph does NOT have node types, it will NOT return neither an error or a panic. Parameters ---------- node_id: int node whose node type is to be returned. Safety ------ Even though the method will return an option when the node types are not available for the current graph, the behaviour is undefined.""" pass def get_node_type_ids_from_node_id(self, node_id: int) -> Optional[List[int]]: """Returns node type of given node. Parameters ---------- node_id: int node whose node type is to be returned.""" pass def get_unchecked_edge_type_id_from_edge_id(self, edge_id: int) -> Optional[int]: """Returns edge type of given edge. This method will panic if the given edge ID is greater than the number of edges in the graph. Furthermore, if the graph does NOT have edge types, it will NOT return neither an error or a panic. Parameters ---------- edge_id: int edge whose edge type is to be returned. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass def get_edge_type_id_from_edge_id(self, edge_id: int) -> Optional[int]: """Returns edge type of given edge. Parameters ---------- edge_id: int edge whose edge type is to be returned.""" pass def get_unchecked_node_type_names_from_node_id(self, node_id: int) -> Optional[List[str]]: """Returns result of option with the node type of the given node id. Parameters ---------- node_id: int The node ID whose node types are to be returned. Safety ------ This method will return an iterator of None values when the graph does not contain node types.""" pass def get_node_type_names_from_node_id(self, node_id: int) -> Optional[List[str]]: """Returns result of option with the node type of the given node id. Parameters ---------- node_id: int The node ID whose node types are to be returned. Raises ------- ValueError If the node types are not available for the current graph instance.""" pass def get_node_type_names_from_node_name(self, node_name: str) -> Optional[List[str]]: """Returns result of option with the node type of the given node name. Parameters ---------- node_name: str The node name whose node types are to be returned.""" pass def get_edge_type_name_from_edge_id(self, edge_id: int) -> Optional[str]: """Returns option with the edge type of the given edge id. Parameters ---------- edge_id: int The edge ID whose edge type is to be returned.""" pass def get_edge_type_name_from_edge_type_id(self, edge_type_id: int) -> str: """Return edge type name of given edge type. Parameters ---------- edge_type_id: int Id of the edge type.""" pass def get_edge_weight_from_edge_id(self, edge_id: int) -> float: """Returns weight of the given edge id. Parameters ---------- edge_id: int The edge ID whose weight is to be returned.""" pass def get_edge_weight_from_node_ids(self, src: int, dst: int) -> float: """Returns weight of the given node ids. Parameters ---------- src: int The node ID of the source node. dst: int The node ID of the destination node.""" pass def get_edge_weight_from_node_ids_and_edge_type_id(self, src: int, dst: int, edge_type: Optional[int]) -> float: """Returns weight of the given node ids and edge type. Parameters ---------- src: int The node ID of the source node. dst: int The node ID of the destination node. edge_type: Optional[int] The edge type ID of the edge.""" pass def get_edge_weight_from_node_names_and_edge_type_name(self, src: str, dst: str, edge_type: Optional[str]) -> float: """Returns weight of the given node names and edge type. Parameters ---------- src: str The node name of the source node. dst: str The node name of the destination node. edge_type: Optional[str] The edge type name of the edge.""" pass def get_edge_weight_from_node_names(self, src_name: str, dst_name: str) -> float: """Returns weight of the given node names. Parameters ---------- src_name: str The node name of the source node. dst_name: str The node name of the destination node.""" pass def get_unchecked_node_name_from_node_id(self, node_id: int) -> str: """Returns result with the node name. Parameters ---------- node_id: int The node ID whose name is to be returned. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass def get_node_name_from_node_id(self, node_id: int) -> str: """Returns result with the node name. Parameters ---------- node_id: int The node ID whose name is to be returned.""" pass def get_node_id_from_node_name(self, node_name: str) -> int: """Returns result with the node ID. Parameters ---------- node_name: str The node name whose node ID is to be returned. Raises ------- ValueError When the given node name does not exists in the current graph.""" pass def get_node_ids_from_node_names(self, node_names: List[str]) -> np.ndarray: """Returns result with the node IDs. Parameters ---------- node_names: List[str] The node names whose node IDs is to be returned. Raises ------- ValueError When any of the given node name does not exists in the current graph.""" pass def get_edge_node_ids_from_edge_node_names(self, edge_node_names: List[Tuple[str, str]]) -> List[Tuple[int, int]]: """Returns result with the edge node IDs. Parameters ---------- edge_node_names: List[Tuple[str, str]] The node names whose node IDs is to be returned. Raises ------- ValueError When any of the given node name does not exists in the current graph.""" pass def get_edge_node_names_from_edge_node_ids(self, edge_node_ids: List[Tuple[int, int]]) -> List[Tuple[str, str]]: """Returns result with the edge node names. Parameters ---------- edge_node_ids: List[Tuple[int, int]] The node names whose node names is to be returned. Raises ------- ValueError When any of the given node IDs does not exists in the current graph.""" pass def get_node_type_ids_from_node_name(self, node_name: str) -> Optional[List[int]]: """Return node type ID for the given node name if available. Parameters ---------- node_name: str Name of the node.""" pass def get_node_type_name_from_node_name(self, node_name: str) -> Optional[List[str]]: """Return node type name for the given node name if available. Parameters ---------- node_name: str Name of the node.""" pass def get_edge_count_from_edge_type_id(self, edge_type_id: Optional[int]) -> int: """Return number of edges with given edge type ID. If None is given as an edge type ID, the unknown edge type IDs will be returned. Parameters ---------- edge_type_id: Optional[int] The edge type ID to count the edges of.""" pass def get_edge_type_id_from_edge_type_name(self, edge_type_name: Optional[str]) -> Optional[int]: """Return edge type ID curresponding to given edge type name. If None is given as an edge type ID, None is returned. Parameters ---------- edge_type_name: Optional[str] The edge type name whose ID is to be returned.""" pass def get_edge_count_from_edge_type_name(self, edge_type_name: Optional[str]) -> int: """Return number of edges with given edge type name. If None is given as an edge type name, the unknown edge types will be returned. Parameters ---------- edge_type_name: Optional[str] The edge type name to count the edges of.""" pass def get_node_type_id_from_node_type_name(self, node_type_name: str) -> int: """Return node type ID curresponding to given node type name. If None is given as an node type ID, None is returned. Parameters ---------- node_type_name: str The node type name whose ID is to be returned.""" pass def get_node_count_from_node_type_id(self, node_type_id: Optional[int]) -> int: """Return number of nodes with given node type ID. If None is given as an node type ID, the unknown node types will be returned. Parameters ---------- node_type_id: Optional[int] The node type ID to count the nodes of.""" pass def get_node_count_from_node_type_name(self, node_type_name: Optional[str]) -> int: """Return number of nodes with given node type name. If None is given as an node type name, the unknown node types will be returned. Parameters ---------- node_type_name: Optional[str] The node type name to count the nodes of.""" pass def get_neighbour_node_ids_from_node_id(self, node_id: int) -> np.ndarray: """Return vector of destinations for the given source node ID. Parameters ---------- node_id: int Node ID whose neighbours are to be retrieved.""" pass def get_neighbour_node_ids_from_node_name(self, node_name: str) -> np.ndarray: """Return vector of destinations for the given source node name. Parameters ---------- node_name: str Node ID whose neighbours are to be retrieved.""" pass def get_neighbour_node_names_from_node_name(self, node_name: str) -> List[str]: """Return vector of destination names for the given source node name. Parameters ---------- node_name: str Node name whose neighbours are to be retrieved.""" pass def get_minmax_edge_ids_from_node_ids(self, src: int, dst: int) -> Tuple[int, int]: """Return range of outbound edges IDs for all the edges bewteen the given source and destination nodes. This operation is meaningfull only in a multigraph. Parameters ---------- src: int Source node. dst: int Destination node.""" pass def get_edge_id_from_node_ids_and_edge_type_id(self, src: int, dst: int, edge_type: Optional[int]) -> int: """Return edge ID for given tuple of nodes and edge type. This method will return an error if the graph does not contain the requested edge with edge type. Parameters ---------- src: int Source node of the edge. dst: int Destination node of the edge. edge_type: Optional[int] Edge Type of the edge.""" pass def get_edge_id_from_node_names(self, src_name: str, dst_name: str) -> int: """Return edge ID for given tuple of node names. This method will return an error if the graph does not contain the requested edge with edge type. Parameters ---------- src_name: str Source node name of the edge. dst_name: str Destination node name of the edge.""" pass def get_edge_id_from_node_names_and_edge_type_name(self, src_name: str, dst_name: str, edge_type_name: Optional[str]) -> int: """Return edge ID for given tuple of node names and edge type name. This method will return an error if the graph does not contain the requested edge with edge type. Parameters ---------- src_name: str Source node name of the edge. dst_name: str Destination node name of the edge. edge_type_name: Optional[str] Edge type name.""" pass def get_edge_type_ids_from_edge_type_names(self, edge_type_names: List[Optional[str]]) -> List[Optional[int]]: """Return translated edge types from string to internal edge ID. Parameters ---------- edge_type_names: List[Optional[str]] Vector of edge types to be converted.""" pass def get_node_type_ids_from_node_type_names(self, node_type_names: List[Optional[str]]) -> List[Optional[int]]: """Return translated node types from string to internal node ID. Parameters ---------- node_type_names: List[Optional[str]] Vector of node types to be converted.""" pass def get_multiple_node_type_ids_from_node_type_names(self, node_type_names: List[Optional[List[str]]]) -> List[Optional[List[int]]]: """Return translated node types from string to internal node ID. Parameters ---------- node_type_names: List[Optional[List[str]]] Vector of node types to be converted. Raises ------- ValueError If the graph does not have node types. ValueError If any of the given node type names do not exists in the graph.""" pass def get_unchecked_minmax_edge_ids_from_source_node_id(self, src: int) -> Tuple[int, int]: """Return range of outbound edges IDs which have as source the given Node. The method will panic if the given source node ID is higher than the number of nodes in the graph. Parameters ---------- src: int Node for which we need to compute the cumulative_node_degrees range. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass def get_minmax_edge_ids_from_source_node_id(self, src: int) -> Tuple[int, int]: """Return range of outbound edges IDs which have as source the given Node. Parameters ---------- src: int Node for which we need to compute the cumulative_node_degrees range.""" pass def get_node_type_name_from_node_type_id(self, node_type_id: int) -> str: """Return node type name of given node type. There is no need for a unchecked version since we will have to map on the note_types anyway. Parameters ---------- node_type_id: int Id of the node type.""" pass def get_unchecked_node_type_names_from_node_type_ids(self, node_type_ids: List[int]) -> List[str]: """Return node type name of given node type. Parameters ---------- node_type_ids: List[int] Id of the node type. Safety ------ The method will panic if the graph does not contain node types.""" pass def is_unchecked_connected_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is not a singleton nor a singleton with selfloop. Parameters ---------- node_id: int The node to be checked for. Safety ------ If the given node ID does not exists in the graph this method will panic.""" pass def is_unchecked_disconnected_node_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a singleton or a singleton with selfloop. Parameters ---------- node_id: int The node to be checked for. Safety ------ If the given node ID does not exists in the graph this method will panic.""" pass def is_unchecked_singleton_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a singleton. Parameters ---------- node_id: int The node to be checked for. Safety ------ If the given node ID does not exists in the graph this method will panic.""" pass def is_singleton_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a singleton. Parameters ---------- node_id: int The node to be checked for.""" pass def is_unchecked_singleton_with_selfloops_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a singleton with self-loops. Parameters ---------- node_id: int The node to be checked for.""" pass def is_singleton_with_selfloops_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a singleton with self-loops. Parameters ---------- node_id: int The node to be checked for.""" pass def is_unchecked_singleton_from_node_name(self, node_name: str) -> bool: """Returns boolean representing if given node is a singleton. Nota that this method will raise a panic if caled with unproper parametrization. Parameters ---------- node_name: str The node name to be checked for. Safety ------ If the given node name does not exist in the graph this method will panic.""" pass def is_singleton_from_node_name(self, node_name: str) -> bool: """Returns boolean representing if given node is a singleton. Parameters ---------- node_name: str The node name to be checked for.""" pass def has_node_name(self, node_name: str) -> bool: """Returns whether the graph has the given node name. Parameters ---------- node_name: str Name of the node.""" pass def has_node_type_id(self, node_type_id: int) -> bool: """Returns whether the graph has the given node type id. Parameters ---------- node_type_id: int id of the node.""" pass def has_node_type_name(self, node_type_name: str) -> bool: """Returns whether the graph has the given node type name. Parameters ---------- node_type_name: str Name of the node.""" pass def has_edge_type_id(self, edge_type_id: int) -> bool: """Returns whether the graph has the given edge type id. Parameters ---------- edge_type_id: int id of the edge.""" pass def has_edge_type_name(self, edge_type_name: str) -> bool: """Returns whether the graph has the given edge type name. Parameters ---------- edge_type_name: str Name of the edge.""" pass def has_edge_from_node_ids(self, src: int, dst: int) -> bool: """Returns whether edge passing between given node ids exists. Parameters ---------- src: int Source node id. dst: int Destination node id.""" pass def has_selfloop_from_node_id(self, node_id: int) -> bool: """Returns whether the given node ID has a selfloop. Parameters ---------- node_id: int Source node id.""" pass def has_edge_from_node_ids_and_edge_type_id(self, src: int, dst: int, edge_type: Optional[int]) -> bool: """Returns whether edge with the given type passing between given nodes exists. Parameters ---------- src: int The source node of the edge. dst: int The destination node of the edge. edge_type: Optional[int] The (optional) edge type.""" pass def is_unchecked_trap_node_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a trap. If the provided node_id is higher than the number of nodes in the graph, the method will panic. Parameters ---------- node_id: int Integer ID of the node, if this is bigger that the number of nodes it will panic. Safety ------ If the given node ID does not exists in the graph this method will panic.""" pass def is_trap_node_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a trap. Parameters ---------- node_id: int Integer ID of the node, if this is bigger that the number of nodes it will panic.""" pass def has_node_name_and_node_type_name(self, node_name: str, node_type_name: Optional[List[str]]) -> bool: """Returns whether the given node name and node type name exist in current graph. Parameters ---------- node_name: str The node name. node_type_name: Optional[List[str]] The node types name.""" pass def has_edge_from_node_names(self, src_name: str, dst_name: str) -> bool: """Returns whether if edge passing between given nodes exists. Parameters ---------- src_name: str The source node name of the edge. dst_name: str The destination node name of the edge.""" pass def has_edge_from_node_names_and_edge_type_name(self, src_name: str, dst_name: str, edge_type_name: Optional[str]) -> bool: """Returns whether if edge with type passing between given nodes exists. Parameters ---------- src_name: str The source node name of the edge. dst_name: str The destination node name of the edge. edge_type_name: Optional[str] The (optional) edge type name.""" pass @staticmethod def generate_random_connected_graph(random_state: Optional[int], minimum_node_id: Optional[int], minimum_node_sampling: Optional[int], maximum_node_sampling: Optional[int], number_of_nodes: Optional[int], include_selfloops: Optional[bool], node_type: Optional[str], edge_type: Optional[str], weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new random connected graph with given sizes and types. Parameters ---------- random_state: int The random state to use to reproduce the sampling. minimum_node_id: int The minimum node ID for the connected graph. minimum_node_sampling: int The minimum amount of nodes to sample per node. maximum_node_sampling: int The maximum amount of nodes to sample per node. number_of_nodes: Optional[int] Number of nodes in the chain. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. node_type: Optional[str] The node type to use for the chain. By default 'chain'. edge_type: Optional[str] The node type to use for the chain. By default 'chain'. weight: Optional[float] The weight to use for the edges in the chain. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Chain'.""" pass @staticmethod def generate_random_spanning_tree(random_state: Optional[int], minimum_node_id: Optional[int], number_of_nodes: Optional[int], include_selfloops: Optional[bool], node_type: Optional[str], edge_type: Optional[str], weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new random connected graph with given sizes and types. Parameters ---------- random_state: int The random state to use to reproduce the sampling. minimum_node_id: int The minimum node ID for the connected graph. minimum_node_sampling: int The minimum amount of nodes to sample per node. maximum_node_sampling: int The maximum amount of nodes to sample per node. number_of_nodes: Optional[int] Number of nodes in the chain. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. node_type: Optional[str] The node type to use for the chain. By default 'chain'. edge_type: Optional[str] The node type to use for the chain. By default 'chain'. weight: Optional[float] The weight to use for the edges in the chain. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Chain'.""" pass @staticmethod def generate_circle_graph(minimum_node_id: Optional[int], number_of_nodes: Optional[int], include_selfloops: Optional[bool], node_type: Optional[str], edge_type: Optional[str], weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new circle graph with given sizes and types. Parameters ---------- minimum_node_id: Optional[int] Minimum node ID to start with. May be needed when circleing graphs. By default 0. number_of_nodes: Optional[int] Number of nodes in the circle. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. node_type: Optional[str] The node type to use for the circle. By default 'circle'. edge_type: Optional[str] The node type to use for the circle. By default 'circle'. weight: Optional[float] The weight to use for the edges in the circle. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Circle'.""" pass @staticmethod def generate_chain_graph(minimum_node_id: Optional[int], number_of_nodes: Optional[int], include_selfloops: Optional[bool], node_type: Optional[str], edge_type: Optional[str], weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new chain graph with given sizes and types. Parameters ---------- minimum_node_id: Optional[int] Minimum node ID to start with. May be needed when chaining graphs. By default 0. number_of_nodes: Optional[int] Number of nodes in the chain. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. node_type: Optional[str] The node type to use for the chain. By default 'chain'. edge_type: Optional[str] The node type to use for the chain. By default 'chain'. weight: Optional[float] The weight to use for the edges in the chain. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Chain'.""" pass @staticmethod def generate_complete_graph(minimum_node_id: Optional[int], number_of_nodes: Optional[int], include_selfloops: Optional[bool], node_type: Optional[str], edge_type: Optional[str], weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new complete graph with given sizes and types. Parameters ---------- minimum_node_id: Optional[int] Minimum node ID to start with. May be needed when combining graphs. By default 0. number_of_nodes: Optional[int] Number of nodes in the chain. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. node_type: Optional[str] The node type to use. By default 'complete'. edge_type: Optional[str] The node type to use. By default 'complete'. weight: Optional[float] The weight to use for the edges. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Complete'.""" pass @staticmethod def generate_barbell_graph(minimum_node_id: Optional[int], left_clique_nodes_number: Optional[int], right_clique_nodes_number: Optional[int], chain_nodes_number: Optional[int], include_selfloops: Optional[bool], left_clique_node_type: Optional[str], right_clique_node_type: Optional[str], chain_node_type: Optional[str], left_clique_edge_type: Optional[str], right_clique_edge_type: Optional[str], chain_edge_type: Optional[str], left_clique_weight: Optional[float], right_clique_weight: Optional[float], chain_weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new barbell graph with given sizes and types. Parameters ---------- minimum_node_id: Optional[int] Minimum node ID to start with. May be needed when chaining graphs. By default 0. left_clique_nodes_number: Optional[int] Number of nodes in the left clique. By default 10. right_clique_nodes_number: Optional[int] Number of nodes in the right clique. By default equal to the left clique. chain_nodes_number: Optional[int] Number of nodes in the chain. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. left_clique_node_type: Optional[str] The node type to use for the left clique. By default 'left_clique'. right_clique_node_type: Optional[str] The node type to use for the right clique. By default 'right_clique'. chain_node_type: Optional[str] The node type to use for the chain. By default 'chain'. left_clique_edge_type: Optional[str] The node type to use for the left clique. By default 'left_clique'. right_clique_edge_type: Optional[str] The node type to use for the right clique. By default 'right_clique'. chain_edge_type: Optional[str] The node type to use for the chain. By default 'chain'. left_clique_weight: Optional[float] The weight to use for the edges in the left clique. By default None. right_clique_weight: Optional[float] The weight to use for the edges in the right clique. By default None. chain_weight: Optional[float] The weight to use for the edges in the chain. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Barbell'. Raises ------- ValueError If the edge weights are provided only for a subset.""" pass def are_nodes_remappable(self, other: Graph) -> bool: """Return whether nodes are remappable to those of the given graph. Parameters ---------- other: Graph graph towards remap the nodes to.""" pass def remap_unchecked_from_node_ids(self, node_ids: List[int]) -> Graph: """Returns graph remapped using given node IDs ordering. Parameters ---------- node_ids: List[int] The node Ids to remap the graph to. Safety ------ This method will cause a panic if the node IDs are either: * Not unique * Not available for each of the node IDs of the graph.""" pass def remap_from_node_ids(self, node_ids: List[int]) -> Graph: """Returns graph remapped using given node IDs ordering. Parameters ---------- node_ids: List[int] The node Ids to remap the graph to. Raises ------- ValueError If the given node IDs are not unique. ValueError If the given node IDs are not available for all the values in the graph.""" pass def remap_from_node_names(self, node_names: List[str]) -> Graph: """Returns graph remapped using given node names ordering. Parameters ---------- node_names: List[str] The node names to remap the graph to. Raises ------- ValueError If the given node names are not unique. ValueError If the given node names are not available for all the values in the graph.""" pass def remap_from_graph(self, other: Graph) -> Graph: """Return graph remapped towards nodes of the given graph. Parameters ---------- other: Graph The graph to remap towards.""" pass def remove_components(self, node_names: Optional[List[str]], node_types: Optional[List[Optional[str]]], edge_types: Optional[List[Optional[str]]], minimum_component_size: Optional[int], top_k_components: Optional[int], verbose: Optional[bool]) -> Graph: """remove all the components that are not connected to interesting nodes and edges. Parameters ---------- node_names: Optional[List[str]] The name of the nodes of which components to keep. node_types: Optional[List[Optional[str]]] The types of the nodes of which components to keep. edge_types: Optional[List[Optional[str]]] The types of the edges of which components to keep. minimum_component_size: Optional[int] Optional, Minimum size of the components to keep. top_k_components: Optional[int] Optional, number of components to keep sorted by number of nodes. verbose: Optional[bool] Whether to show the loading bar.""" pass def replace(self, node_name_mapping: Optional[Dict[str, str]], node_type_name_mapping: Optional[Dict[str, str]], edge_type_name_mapping: Optional[Dict[str, str]]) -> Graph: """Replace given node, node type and edge type names. Parameters ---------- node_name_mapping: Optional[Dict[str, str]] The node names to replace. node_type_name_mapping: Optional[Dict[str, str]] The node type names to replace. edge_type_name_mapping: Optional[Dict[str, str]] The edge type names to replace. Raises ------- ValueError If the given node names mapping would lead to nodes duplication.""" pass def report(self) -> Dict[str, str]: """Returns report relative to the graph metrics The report includes the following metrics by default: * Name of the graph * Whether the graph is directed or undirected * Number of singleton nodes * Number of nodes - If the graph has nodes, we also compute: * Minimum unweighted node degree * Maximum unweighted node degree * Unweighted node degree mean * Number of edges * Number of self-loops * Number of singleton with self-loops * Whether the graph is a multigraph * Number of parallel edges * Number of directed edges - If the graph has edges, we also compute: * Rate of self-loops * Whether the graph has weighted edges - If the graph has weights, we also compute: * Minimum weighted node degree * Maximum weighted node degree * Weighted node degree mean * The total edge weights * Whether the graph has node types - If the graph has node types, we also compute: * Whether the graph has singleton node types * The number of node types * The number of nodes with unknown node types * The number of nodes with known node types * Whether the graph has edge types - If the graph has edge types, we also compute: * Whether the graph has singleton edge types * The number of edge types * The number of edges with unknown edge types * The number of edges with known edge types On request, since it takes more time to compute it, the method also provides:""" pass def overlap_textual_report(self, other: Graph, verbose: Optional[bool]) -> str: """Return rendered textual report about the graph overlaps. Parameters ---------- other: Graph graph to create overlap report with. verbose: Optional[bool] Whether to shor the loading bars.""" pass def get_node_report_from_node_id(self, node_id: int) -> str: """Return human-readable html report of the given node. The report, by default, is rendered using html. Parameters ---------- node_id: int Whether to show a loading bar in graph operations.""" pass def get_node_report_from_node_name(self, node_name: str) -> str: """Return human-readable html report of the given node. The report, by default, is rendered using html. Parameters ---------- node_name: str Whether to show a loading bar in graph operations.""" pass def textual_report(self) -> str: """Return html short textual report of the graph. TODO! Add reports on triangles TODO! Add reports on connected components TODO! Add reports on various node metrics TODO! Add reports on various edge metrics NOTE! Most of the above TODOs will require first to implement the support for the fast computation of the inbound edges in a directed graphs""" pass def add_selfloops(self, edge_type_name: Optional[str], weight: Optional[float]) -> Graph: """Returns new graph with added in missing self-loops with given edge type and weight. Parameters ---------- Raises ------- ValueError If the edge type for the new selfloops is provided but the graph does not have edge types. ValueError If the edge weight for the new selfloops is provided but the graph does not have edge weights. ValueError If the edge weight for the new selfloops is NOT provided but the graph does have edge weights.""" pass def set_inplace_all_edge_types(self, edge_type: str): """Replace all edge types (if present) and set all the edge to edge_type. This happens INPLACE, that is edits the current graph instance. Parameters ---------- edge_type: str The edge type to assing to all the edges. Raises ------- ValueError If the graph does not have edges. ValueError If the graph is a multigraph.""" pass def set_all_edge_types(self, edge_type: str) -> Graph: """Replace all edge types (if present) and set all the edge to edge_type. This DOES NOT happen inplace, but created a new instance of the graph. Parameters ---------- edge_type: str The edge type to assing to all the edges.""" pass def set_inplace_all_node_types(self, node_type: str): """Replace all node types (if present) and set all the node to node_type. Parameters ---------- node_type: str The node type to assing to all the nodes.""" pass def set_all_node_types(self, node_type: str) -> Graph: """Replace all node types (if present) and set all the node to node_type. This DOES NOT happen inplace, but created a new instance of the graph. Parameters ---------- node_type: str The node type to assing to all the nodes.""" pass def remove_inplace_node_type_ids(self, node_type_ids_to_remove: List[int]): """Remove given node type ID from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification happens inplace. Parameters ---------- node_type_id_to_remove: int The node type ID to remove. Raises ------- ValueError If the graph does not have node types. ValueError If the given node type ID does not exists in the graph.""" pass def remove_inplace_singleton_node_types(self): """Remove singleton node types from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification happens inplace. Raises ------- ValueError If the graph does not have node types.""" pass def remove_inplace_edge_type_ids(self, edge_type_ids_to_remove: List[int]): """Remove given edge type ID from all edges. Parameters ---------- edge_type_id: int The edge type ID to remove. Raises ------- ValueError If the graph is a multigraph. ValueError If the graph does not have edge types. ValueError If the given edge type ID does not exists in the graph.""" pass def remove_inplace_singleton_edge_types(self): """Remove singleton edge types from all edges. If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification happens inplace. Raises ------- ValueError If the graph does not have edge types.""" pass def remove_inplace_node_type_name(self, node_type_name: str): """Remove given node type name from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification happens inplace. Parameters ---------- node_type_name: str The node type ID to remove. Raises ------- ValueError If the graph does not have node types. ValueError If the given node type name does not exists in the graph.""" pass def remove_node_type_id(self, node_type_id: int) -> Graph: """Remove given node type ID from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification DOES NOT happen inplace. Parameters ---------- node_type_id: int The node type ID to remove. Raises ------- ValueError If the graph does not have node types. ValueError If the given node type ID does not exists in the graph.""" pass def remove_singleton_node_types(self) -> Graph: """Remove singleton node types from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification DOES NOT happen inplace. Raises ------- ValueError If the graph does not have node types.""" pass def remove_node_type_name(self, node_type_name: str) -> Graph: """Remove given node type name from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification DOES NOT happen inplace. Parameters ---------- node_type_name: str The node type ID to remove. Raises ------- ValueError If the graph does not have node types. ValueError If the given node type name does not exists in the graph.""" pass def remove_inplace_edge_type_name(self, edge_type_name: str): """Remove given edge type name from all edges. If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification happens inplace. Parameters ---------- edge_type_name: str The edge type ID to remove. Raises ------- ValueError If the graph does not have edge types. ValueError If the given edge type name does not exists in the graph.""" pass def remove_edge_type_id(self, edge_type_id: int) -> Graph: """Remove given edge type ID from all edges. If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification DOES NOT happen inplace. Parameters ---------- edge_type_id: int The edge type ID to remove. Raises ------- ValueError If the graph does not have edge types. ValueError If the given edge type ID does not exists in the graph.""" pass def remove_singleton_edge_types(self) -> Graph: """Remove singleton edge types from all edges. If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification DOES NOT happen inplace. Raises ------- ValueError If the graph does not have edge types.""" pass def remove_edge_type_name(self, edge_type_name: str) -> Graph: """Remove given edge type name from all edges. If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification DOES NOT happen inplace. Parameters ---------- edge_type_name: str The edge type ID to remove. Raises ------- ValueError If the graph does not have edge types. ValueError If the given edge type name does not exists in the graph.""" pass def remove_inplace_node_types(self): """Remove node types from the graph. Note that the modification happens inplace. Raises ------- ValueError If the graph does not have node types.""" pass def remove_node_types(self) -> Graph: """Remove node types from the graph. Note that the modification does not happen inplace. Raises ------- ValueError If the graph does not have node types.""" pass def remove_inplace_edge_types(self): """Remove edge types from the graph. Note that the modification happens inplace. Raises ------- ValueError If the graph does not have edge types. ValueError If the graph is a multigraph.""" pass def remove_edge_types(self) -> Graph: """Remove edge types from the graph. Note that the modification does not happen inplace. Raises ------- ValueError If the graph does not have edge types.""" pass def remove_inplace_edge_weights(self): """Remove edge weights from the graph. Note that the modification happens inplace. Raises ------- ValueError If the graph does not have edge weights.""" pass def remove_edge_weights(self) -> Graph: """Remove edge weights from the graph. Note that the modification does not happen inplace. Raises ------- ValueError If the graph does not have edge weights.""" pass def sort_by_increasing_outbound_node_degree(self) -> Graph: """Returns graph with node IDs sorted by increasing outbound node degree""" pass def sort_by_decreasing_outbound_node_degree(self) -> Graph: """Returns graph with node IDs sorted by decreasing outbound node degree""" pass def sort_by_node_lexicographic_order(self) -> Graph: """Returns graph with node IDs sorted by lexicographic order""" pass def get_bfs_topological_sorting_from_node_id(self, root_node_id: int) -> np.ndarray: """Returns topological sorting map using breadth-first search from the given node. Parameters ---------- root_node_id: int Node ID of node to be used as root of BFS Raises ------- ValueError If the given root node ID does not exist in the graph""" pass def get_reversed_bfs_topological_sorting_from_node_id(self, root_node_id: int) -> np.ndarray: """Returns topological sorting reversed map using breadth-first search from the given node. Parameters ---------- root_node_id: int Node ID of node to be used as root of BFS Raises ------- ValueError If the given root node ID does not exist in the graph""" pass def sort_by_bfs_topological_sorting_from_node_id(self, root_node_id: int) -> Graph: """Returns graph with node IDs sorted using a BFS Parameters ---------- root_node_id: int Node ID of node to be used as root of BFS Raises ------- ValueError If the given root node ID does not exist in the graph""" pass def get_sparse_edge_weighting_methods(self) -> List[str]: """Return list of the supported sparse edge weighting methods""" pass def get_edge_weighting_methods(self) -> List[str]: """Return list of the supported edge weighting methods""" pass def strongly_connected_components(self) -> List[Set[int]]: """Returns list of nodes of the various strongly connected components. This is an implementation of Tarjan algorithm.""" pass def generate_new_edges_from_node_features(self, features: List[List[float]], neighbours_number: Optional[int], max_degree: Optional[int], distance_name: Optional[str], verbose: Optional[bool]) -> Graph: """Returns graph with edges added extracted from given node_features. This operation might distrupt the graph topology. Proceed with caution! Parameters ---------- features: List[List[float]] node_features to use to identify the new neighbours. neighbours_number: Optional[int] Number of neighbours to add. max_degree: Optional[int] The maximum degree a node can have its neighbours augmented. By default 0, that is, only singletons are augmented. distance_name: Optional[str] Name of distance to use. Can either be L2 or COSINE. By default COSINE. verbose: Optional[bool] Whether to show loading bars. Raises ------- ValueError If the graph does not have nodes. ValueError If the given node_features are not provided exactly for each node. ValueError If the node_features do not have a consistent shape. ValueError If the provided number of neighbours is zero.""" pass def to_directed_inplace(self): """Convert inplace the graph to directed.""" pass def to_directed(self) -> Graph: """Return a new instance of the current graph as directed""" pass def to_upper_triangular(self) -> Graph: """Return the directed graph from the upper triangular adjacency matrix.""" pass def to_lower_triangular(self) -> Graph: """Return the directed graph from the lower triangular adjacency matrix.""" pass def to_main_diagonal(self) -> Graph: """Return the graph from the main diagonal adjacency matrix.""" pass def to_anti_diagonal(self) -> Graph: """Return the graph from the anti-diagonal adjacency matrix.""" pass def to_bidiagonal(self) -> Graph: """Return the graph from the bidiagonal adjacency matrix.""" pass def to_arrowhead(self) -> Graph: """Return the graph from the arrowhead adjacency matrix.""" pass def to_transposed(self) -> Graph: """Return the graph from the transposed adjacency matrix.""" pass def to_complementary(self) -> Graph: """Return the complementary graph.""" pass def get_transitive_closure(self, iterations: Optional[int], verbose: Optional[bool]) -> Graph: """Returns graph to the i-th transitivity closure iteration. Parameters ---------- iterations: Optional[int] The number of iterations of the transitive closure to execute. If None, the complete transitive closure is computed. verbose: Optional[bool] Whether to show a loading bar while building the graph.""" pass def get_all_shortest_paths(self, iterations: Optional[int], verbose: Optional[bool]) -> Graph: """Returns graph with unweighted shortest paths computed up to the given depth. The returned graph will have no selfloops. Parameters ---------- iterations: Optional[int] The number of iterations of the transitive closure to execute. If None, the complete transitive closure is computed. verbose: Optional[bool] Whether to show a loading bar while building the graph.""" pass def get_weighted_all_shortest_paths(self, iterations: Optional[int], use_edge_weights_as_probabilities: Optional[bool], verbose: Optional[bool]) -> Graph: """Returns graph with weighted shortest paths computed up to the given depth. The returned graph will have no selfloops. Parameters ---------- iterations: Optional[int] The number of iterations of the transitive closure to execute. If None, the complete transitive closure is computed. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. verbose: Optional[bool] Whether to show a loading bar while building the graph. Raises ------- ValueError If the graph does not have weights. ValueError If the graph contains negative weights. ValueError If the user has asked for the weights to be treated as probabilities but the weights are not between 0 and 1.""" pass def random_spanning_arborescence_kruskal(self, random_state: Optional[int], undesired_edge_types: Optional[Set[Optional[int]]], verbose: Optional[bool]) -> Tuple[Set[Tuple[int, int]], List[int], int, int, int]: """Returns set of edges composing a spanning tree and connected components. The spanning tree is NOT minimal. The given random_state is NOT the root of the tree. This method, additionally, allows for undesired edge types to be used to build the spanning tree only in extremis when it is utterly necessary in order to complete the spanning arborescence. The quintuple returned contains: - Set of the edges used in order to build the spanning arborescence. - Vector of the connected component of each node. - Number of connected components. - Minimum component size. - Maximum component size. Parameters ---------- random_state: Optional[int] The random_state to use for the holdout, undesired_edge_types: Optional[Set[Optional[int]]] Which edge types id to try to avoid. verbose: Optional[bool] Whether to show a loading bar or not.""" pass def spanning_arborescence_kruskal(self, verbose: Optional[bool]) -> Tuple[Set[Tuple[int, int]], List[int], int, int, int]: """Returns consistent spanning arborescence using Kruskal. The spanning tree is NOT minimal. The quintuple returned contains: - Set of the edges used in order to build the spanning arborescence. - Vector of the connected component of each node. - Number of connected components. - Minimum component size. - Maximum component size. Parameters ---------- verbose: Optional[bool] Whether to show a loading bar or not.""" pass def connected_components(self, verbose: Optional[bool]) -> Tuple[List[int], int, int, int]: """Compute the connected components building in parallel a spanning tree using [bader's algorithm](https://www.sciencedirect.com/science/article/abs/pii/S0743731505000882). **This works only for undirected graphs.** This method is **not thread save and not deterministic** but by design of the algorithm this shouldn't matter but if we will encounter non-detemristic bugs here is where we want to look. The returned quadruple contains: - Vector of the connected component for each node. - Number of connected components. - Minimum connected component size. - Maximum connected component size. Parameters ---------- verbose: Optional[bool] Whether to show a loading bar or not. Raises ------- ValueError If the given graph is directed. ValueError If the system configuration does not allow for the creation of the thread pool.""" pass def approximated_vertex_cover_set(self) -> Set[int]: """Returns 2-approximated verted cover set using greedy algorithm.""" pass def to_dot(self) -> str: """Print the current graph in a format compatible with Graphviz dot's format""" pass def _repr_html_(self) -> str: """""" pass def cooccurence_matrix(self, walk_length: int, **kwargs) -> Tuple[np.ndarray, np.ndarray, np.ndarray]: """Return cooccurence matrix-based triples of words, contexts and frequencies. Parameters --------------------- walk_length: int Maximal length of the random walk. On graphs without traps, all walks have this length. window_size: int = 4 Size of the window for local contexts. iterations: int = 1 Number of cycles on the graphs to execute. return_weight: float = 1.0 Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper. explore_weight: float = 1.0 Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper. change_node_type_weight: float = 1.0 Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact. change_edge_type_weight: float = 1.0 Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact. dense_node_mapping: Dict[int, int] = None Mapping to use for converting sparse walk space into a dense space. This object can be created using the method available from graph called `get_dense_node_mapping` that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. max_neighbours: int = None Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk. random_state: int = 42 random_state to use to reproduce the walks. verbose: int = True whether to show or not the loading bar of the walks. Returns ---------------------------- Triple with integer vectors of words and contexts and max-min normalized frequencies.""" pass def node2vec(self, batch_size: int, walk_length: int, window_size: int, **kwargs) -> Tuple[np.ndarray, np.ndarray]: """Return training batches for Node2Vec models. The batch is composed of a tuple as the following: - (Contexts indices, central nodes indices): the tuple of nodes This does not provide any output value as the model uses NCE loss and basically the central nodes that are fed as inputs work as the outputs value. Parameters --------------------- batch_size: int Number of walks to include within this batch. In some pathological cases, this might leed to an empty batch. These cases include graphs with particularly high number of traps. Consider using the method graph.report() to verify if this might apply to your use case. walk_length: int Maximal length of the random walk. On graphs without traps, all walks have this length. window_size: int Size of the window for local contexts. iterations: int = 1 Number of iterations for each node. return_weight: float = 1.0 Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper. explore_weight: float = 1.0 Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper. change_node_type_weight: float = 1.0 Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact. change_edge_type_weight: float = 1.0 Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact. dense_node_mapping: Dict[int, int] Mapping to use for converting sparse walk space into a dense space. This object can be created using the method available from graph called `get_dense_node_mapping` that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. max_neighbours: int = None Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk. random_state: int random_state to use to reproduce the walks. Returns ---------------------------- Tuple with vector of integer with contexts and words.""" pass def get_node_label_prediction_mini_batch(self, idx: int, batch_size: Optional[int], include_central_node: Optional[bool], return_edge_weights: Optional[bool], max_neighbours: Optional[int]) -> Tuple[Tuple[List[List[int]], Optional[List[List[float]]]], np.ndarray, ]: """Return iterator over neighbours for the given node Parameters ----------------------------- `idx`: int - Seed for the batch. `batch_size`: Optional[int] = 1024 - The dimension of the batch. `include_central_node`: Optional[bool] - Whether to include the central node. `return_edge_weights`: Optional[bool] - Whether to return the edge weights. `max_neighbours`: Optional[int] - Maximal number of neighbours to sample. Returns ----------------------------- Tuple with input nodes, optionally edge weights and one-hot encoded node types.""" pass def get_edge_prediction_mini_batch(self, idx: int, batch_size: Optional[int], negative_samples_rate: Optional[float], return_node_types: Optional[bool], return_edge_types: Optional[bool], return_edge_metrics: Optional[bool], avoid_false_negatives: Optional[bool], maximal_sampling_attempts: Optional[int], shuffle: Optional[bool], graph_to_avoid: Optional[Graph]) -> Tuple[np.ndarray, Optional[np.ndarray], np.ndarray, Optional[np.ndarray], Optional[np.ndarray], Optional[np.ndarray], np.ndarray, ]: """Returns n-ple with index to build numpy array, source node, source node type, destination node, destination node type, edge type and whether this edge is real or artificial. Parameters ------------- idx: int The index of the batch to generate, behaves like a random random_state, batch_size: Optional[int] The maximal size of the batch to generate, negative_samples: Optional[float] The component of netagetive samples to use. return_node_types: Optional[bool] Whether to return the source and destination nodes node types. return_edge_types: Optional[bool] Whether to return the edge types. The negative edges edge type will be samples at random. return_edge_metrics: Optional[bool] Whether to return the edge metrics. avoid_false_negatives: Optional[bool] Whether to remove the false negatives when generated. It should be left to false, as it has very limited impact on the training, but enabling this will slow things down. maximal_sampling_attempts: Optional[int] Number of attempts to execute to sample the negative edges. shuffle: Optional[bool] Whether to shuffle the samples within the batch. graph_to_avoid: Optional[Graph] The graph whose edges are to be avoided during the generation of false negatives, Raises --------- ValueError If the given amount of negative samples is not a positive finite real value. ValueError If node types are requested but the graph does not contain any. ValueError If node types are requested but the graph contains unknown node types. ValueError If edge types are requested but the graph does not contain any. ValueError If edge types are requested but the graph contains unknown edge types.""" pass def get_unchecked_edge_prediction_metrics(self, source_node_ids: List[int], destination_node_ids: List[int], normalize: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Returns all available edge prediction metrics for given edges. The metrics returned are, in order: - Adamic Adar index - Jaccard Coefficient - Resource Allocation index - Normalized preferential attachment score Parameters ---------- source_node_ids: List[int] List of source node IDs. destination_node_ids: List[int] List of destination node IDs. normalize: Optional[bool] = True Whether to normalize the metrics. verbose: Optional[bool] = True Whether to show a loading bar. Returns ------- 2D numpy array with metrics.""" pass def get_edge_prediction_metrics(self, normalize: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Returns all available edge prediction metrics for given edges. The metrics returned are, in order: - Adamic Adar index - Jaccard Coefficient - Resource Allocation index - Normalized preferential attachment score Parameters ---------- normalize: Optional[bool] = True Whether to normalize the metrics. verbose: Optional[bool] = True Whether to show a loading bar. Returns ------- 2D numpy array with metrics.""" pass
This is the main struct in Ensmallen, it allows to load and manipulate Graphs efficently.
You are not supposed to directly instantiate this struct but instead you should use the
static method from_csv
, which allows to load the graph from an edge-list.
To get information about a loaded graph, you can call the textual_report
method which
generates an human-readable HTML report.
By default we use EliasFano to store the Adjacency Matrix, this allows to save memory but
is slower than a CSR. For this reason you can use the enable
method to enable optimizzations
which speeds up the operations at the cost of more memory usage. You can check the memory usage
in bytes using get_total_memory_used
and you can get a detailed memory report of each data-structure
inside Graph using memory_stats
.
You can pre-compute the memory needed (in bits) to store the adjacency matrix of a Graph with $|E|$ edges and $|V|$ nodes: $$2 |E| + |E| \left\lceil \log_2 \frac{|V|^2}{|E|} \right\rceil$$
Most Graph properties are automatically cached to speed up.
View Source
def dump_edges(self, path: str, **kwargs): """Write to disk the edges (and optionally the metadata) of the graph. Parameters ---------- path: str Path where to save the edges and their metadata. verbose: bool = True Wether to show a loading bar while writing to file. separator: str = "\t" What separator to use while writing out to file. header: bool = True Wether to write out the header of the file. sources_column_number: int = 0 The column number where to write out the file. sources_column: str = "subject" The name of the column where to write out the file. destinations_column_number: int = 1 The column number where to write out the file. destinations_column: str = "object" The name of the column where to write out the file. edge_types_column_number: int = 2 The column number where to write out the file. edges_type_column: str = "label" The name of the column where to write out the file. weights_column_number: int = 3 The column number where to write out the file. weights_column: str = "weight" The name of the column where to write out the file. numeric_node_ids: bool = False whether to save the internal numeric Ids instead of the string names. directed: bool = False whether to save graph as directed or undirected. Raises ------ TODO: update the set of exceptions""" pass
Write to disk the edges (and optionally the metadata) of the graph.
Parameters
- path (str): Path where to save the edges and their metadata.
- verbose (bool = True): Wether to show a loading bar while writing to file.
- separator (str = " "): What separator to use while writing out to file.
- header (bool = True): Wether to write out the header of the file.
- sources_column_number (int = 0): The column number where to write out the file.
- sources_column (str = "subject"): The name of the column where to write out the file.
- destinations_column_number (int = 1): The column number where to write out the file.
- destinations_column (str = "object"): The name of the column where to write out the file.
- edge_types_column_number (int = 2): The column number where to write out the file.
- edges_type_column (str = "label"): The name of the column where to write out the file.
- weights_column_number (int = 3): The column number where to write out the file.
- weights_column (str = "weight"): The name of the column where to write out the file.
- numeric_node_ids (bool = False): whether to save the internal numeric Ids instead of the string names.
- directed (bool = False): whether to save graph as directed or undirected.
Raises
- TODO (update the set of exceptions):
View Source
def hash(self) -> int: """Returns a 64-bit hash of the graph.""" pass
Returns a 64-bit hash of the graph.
View Source
def get_laplacian_coo_matrix(self) -> Tuple[np.ndarray, np.ndarray]: """Return tuple with edge node IDs and edge weights.""" pass
Return tuple with edge node IDs and edge weights.
View Source
def get_random_walk_normalized_laplacian_coo_matrix(self) -> Tuple[np.ndarray, np.ndarray]: """Return tuple with edge node IDs and edge weights.""" pass
Return tuple with edge node IDs and edge weights.
View Source
def get_symmetric_normalized_laplacian_coo_matrix(self) -> Tuple[np.ndarray, np.ndarray]: """Return tuple with edge node IDs and edge weights.""" pass
Return tuple with edge node IDs and edge weights.
View Source
def get_symmetric_normalized_coo_matrix(self) -> Tuple[np.ndarray, np.ndarray]: """Return tuple with edge node IDs and edge weights.""" pass
Return tuple with edge node IDs and edge weights.
View Source
def dump_nodes(self, path: str, **kwargs): """Write to disk the nodes (and optionally the metadata) of the graph. Parameters ---------- path: str Path where to save the nodes and their metadata. verbose: bool = True Wether to show a loading bar while writing to file. separator: str = "\t" What separator to use while writing out to file. header: bool = True Wether to write out the header of the file. nodes_column_number: int = 0 The column number where to write the nodes. nodes_column: str = "id" The name of the column of the nodes. node_types_column_number: int = 1 The column number where to write the node types. nodes_type_column: str = "category" The name of the column of the node types. Raises ------ TODO: update the set of exceptions""" pass
Write to disk the nodes (and optionally the metadata) of the graph.
Parameters
- path (str): Path where to save the nodes and their metadata.
- verbose (bool = True): Wether to show a loading bar while writing to file.
- separator (str = " "): What separator to use while writing out to file.
- header (bool = True): Wether to write out the header of the file.
- nodes_column_number (int = 0): The column number where to write the nodes.
- nodes_column (str = "id"): The name of the column of the nodes.
- node_types_column_number (int = 1): The column number where to write the node types.
- nodes_type_column (str = "category"): The name of the column of the node types.
Raises
- TODO (update the set of exceptions):
View Source
def get_subgraphs(self, number_of_nodes_to_sample: int, random_state: int, root_node: Optional[int], node_sampling_method: str, edge_weighting_methods: List[str], add_selfloops_where_missing: Optional[bool], unique: Optional[bool]) -> Tuple[np.ndarray, List[np.ndarray]]: """Return subsampled nodes according to the given method and parameters. Parameters ---------- number_of_nodes_to_sample: int the number of nodes to sample. random_state: int The random state to reproduce the sampling. root_node: Optional[int] The (optional) root node to use to sample. In not provided, a random one is sampled. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. edge_weighting_methods: List[str] The edge weighting methods to use to compute the adjacency matrix. add_selfloops_where_missing: Optional[bool] Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true. unique: Optional[bool] = True Whether to reduce the sampled nodes to a unique set. Raises ------ ValueError If the given node sampling method is not supported. ValueError If any of the given subgraph edge weighting method is not supported. ValueError If the list of requested edge weighting methods is empty. ValueError If the `add_selfloops_where_missing` parameter is provided, but the edge weighting method is not laplacian. Returns ------- Tuple with the sampled nodes and the computed kernels.""" pass
Return subsampled nodes according to the given method and parameters.
Parameters
- number_of_nodes_to_sample (int): the number of nodes to sample.
- random_state (int): The random state to reproduce the sampling.
- root_node (Optional[int]): The (optional) root node to use to sample. In not provided, a random one is sampled.
- node_sampling_method (str): The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based.
- edge_weighting_methods (List[str]): The edge weighting methods to use to compute the adjacency matrix.
- add_selfloops_where_missing (Optional[bool]): Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true.
- unique (Optional[bool] = True): Whether to reduce the sampled nodes to a unique set.
Raises
- ValueError: If the given node sampling method is not supported.
- ValueError: If any of the given subgraph edge weighting method is not supported.
- ValueError: If the list of requested edge weighting methods is empty.
- ValueError: If the
add_selfloops_where_missing
parameter is provided, but the edge weighting method is not laplacian.
Returns
- Tuple with the sampled nodes and the computed kernels.
View Source
def get_edge_ids_from_node_ids(self, node_ids: List[int], add_selfloops_where_missing: Optional[bool], complete: Optional[bool]) -> np.ndarray: """Return subsampled edges connected to the given node Ids. Parameters -------------------- node_ids: Vec<NodeT> List of nodes whose edges are to return. add_selfloops_where_missing: Optional[bool] Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true. complete: Optional[bool] = True Whether to return the edges in both directions (when dealing with an undirected graph). Returns -------------------- Tuple with the sampled nodes and the computed kernels.""" pass
Return subsampled edges connected to the given node Ids.
Parameters
- node_ids (Vec
): List of nodes whose edges are to return. - add_selfloops_where_missing (Optional[bool]): Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true.
- complete (Optional[bool] = True): Whether to return the edges in both directions (when dealing with an undirected graph).
Returns
- Tuple with the sampled nodes and the computed kernels.
View Source
def get_sparse_subgraphs(self, number_of_nodes_to_sample: int, random_state: int, root_node: Optional[int], node_sampling_method: str, edge_weighting_methods: List[str], add_selfloops_where_missing: Optional[bool], unique: Optional[bool]) -> Tuple[np.ndarray, List[Tuple[np.ndarray, np.ndarray]], ]: """Return subsampled nodes according to the given method and parameters. Parameters -------------------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to reproduce the sampling. root_node: Optional[int] The (optional) root node to use to sample. In not provided, a random one is sampled. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. edge_weighting_methods: List[str] The edge weighting methods to use to compute the adjacency matrix. add_selfloops_where_missing: Optional[bool] Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true. unique: Optional[bool] = True Whether to reduce the sampled nodes to a unique set. Raises -------------------- ValueError If the given node sampling method is not supported. ValueError If any of the given subgraph edge weighting method is not supported. ValueError If the list of requested edge weighting methods is empty. ValueError If the `add_selfloops_where_missing` parameter is provided, but the edge weighting method is not laplacian. Returns -------------------- Tuple with the sampled nodes and the computed kernels.""" pass
Return subsampled nodes according to the given method and parameters.
Parameters
- number_of_nodes_to_sample (int): The number of nodes to sample.
- random_state (int): The random state to reproduce the sampling.
- root_node (Optional[int]): The (optional) root node to use to sample. In not provided, a random one is sampled.
- node_sampling_method (str): The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based.
- edge_weighting_methods (List[str]): The edge weighting methods to use to compute the adjacency matrix.
- add_selfloops_where_missing (Optional[bool]): Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true.
- unique (Optional[bool] = True): Whether to reduce the sampled nodes to a unique set.
Raises
- ValueError: If the given node sampling method is not supported.
- ValueError: If any of the given subgraph edge weighting method is not supported.
- ValueError: If the list of requested edge weighting methods is empty.
- ValueError: If the
add_selfloops_where_missing
parameter is provided, but the edge weighting method is not laplacian.
Returns
- Tuple with the sampled nodes and the computed kernels.
View Source
def get_sparse_undirected_laplacian_subgraphs(self, number_of_nodes_to_sample: int, random_state: int, root_node: Optional[int], node_sampling_method: str) -> Tuple[np.ndarray, List[Tuple[np.ndarray, np.ndarray]], ]: """Return subsampled nodes and edges using laplacian assuming undirected graph with selfloops. Parameters -------------------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to reproduce the sampling. root_node: Optional[int] The (optional) root node to use to sample. In not provided, a random one is sampled. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. Raises -------------------- TODO: Update Returns -------------------- Tuple with the sampled nodes and the computed kernels.""" pass
Return subsampled nodes and edges using laplacian assuming undirected graph with selfloops.
Parameters
- number_of_nodes_to_sample (int): The number of nodes to sample.
- random_state (int): The random state to reproduce the sampling.
- root_node (Optional[int]): The (optional) root node to use to sample. In not provided, a random one is sampled.
- node_sampling_method (str): The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based.
Raises
- TODO (Update):
Returns
- Tuple with the sampled nodes and the computed kernels.
View Source
def get_edge_prediction_subgraphs(self, number_of_nodes_to_sample: int, random_state: int, node_sampling_method: str, edge_weighting_methods: List[str], add_selfloops_where_missing: Optional[bool]) -> Tuple[np.ndarray, List[np.ndarray], np.ndarray, List[np.ndarray], np.ndarray, ]: """Return subsampled nodes according to the given method and parameters. Parameters -------------------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to reproduce the sampling. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. edge_weighting_methods: List[str] The edge weighting methods to use to compute the adjacency matrix. add_selfloops_where_missing: Optional[bool] Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true. Raises -------------------- ValueError If the given node sampling method is not supported. ValueError If any of the given subgraph edge weighting method is not supported. ValueError If the list of requested edge weighting methods is empty. ValueError If the `add_selfloops_where_missing` parameter is provided, but the edge weighting method is not laplacian. Returns -------------------- Tuple with the sampled nodes and the computed kernels.""" pass
Return subsampled nodes according to the given method and parameters.
Parameters
- number_of_nodes_to_sample (int): The number of nodes to sample.
- random_state (int): The random state to reproduce the sampling.
- node_sampling_method (str): The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based.
- edge_weighting_methods (List[str]): The edge weighting methods to use to compute the adjacency matrix.
- add_selfloops_where_missing (Optional[bool]): Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true.
Raises
- ValueError: If the given node sampling method is not supported.
- ValueError: If any of the given subgraph edge weighting method is not supported.
- ValueError: If the list of requested edge weighting methods is empty.
- ValueError: If the
add_selfloops_where_missing
parameter is provided, but the edge weighting method is not laplacian.
Returns
- Tuple with the sampled nodes and the computed kernels.
View Source
def get_edge_prediction_subgraphs_from_node_ids(self, number_of_nodes_to_sample: int, random_state: int, source_root_node: int, destination_root_node: int, node_sampling_method: str, edge_weighting_methods: List[str], add_selfloops_where_missing: Optional[bool], unique: Optional[bool]) -> Tuple[np.ndarray, List[np.ndarray], np.ndarray, List[np.ndarray], bool, ]: """Return subsampled nodes according to the given method and parameters. Parameters ---------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to reproduce the sampling. source_root_node: int The source root node to use to sample. In not provided, a random one is sampled. destination_root_node: int The destination root node to use to sample. In not provided, a random one is sampled. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. edge_weighting_methods: List[str] The edge weighting methods to use to compute the adjacency matrix. add_selfloops_where_missing: Optional[bool] Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true. unique: Optional[bool] = True Whether to reduce the sampled nodes to a unique set. Raises ------ ValueError If the given node sampling method is not supported. ValueError If any of the given subgraph edge weighting method is not supported. ValueError If the list of requested edge weighting methods is empty. ValueError If the `add_selfloops_where_missing` parameter is provided, but the edge weighting method is not laplacian. Returns ------- Tuple with the sampled nodes and the computed kernels.""" pass
Return subsampled nodes according to the given method and parameters.
Parameters
- number_of_nodes_to_sample (int): The number of nodes to sample.
- random_state (int): The random state to reproduce the sampling.
- source_root_node (int): The source root node to use to sample. In not provided, a random one is sampled.
- destination_root_node (int): The destination root node to use to sample. In not provided, a random one is sampled.
- node_sampling_method (str): The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based.
- edge_weighting_methods (List[str]): The edge weighting methods to use to compute the adjacency matrix.
- add_selfloops_where_missing (Optional[bool]): Whether to add selfloops where they are missing. This parameter only applies to laplacian edge weighting method. By default, true.
- unique (Optional[bool] = True): Whether to reduce the sampled nodes to a unique set.
Raises
- ValueError: If the given node sampling method is not supported.
- ValueError: If any of the given subgraph edge weighting method is not supported.
- ValueError: If the list of requested edge weighting methods is empty.
- ValueError: If the
add_selfloops_where_missing
parameter is provided, but the edge weighting method is not laplacian.
Returns
- Tuple with the sampled nodes and the computed kernels.
View Source
def spanning_arborescence(self, verbose: Optional[bool]) -> np.ndarray: """Returns set of edges forming the spanning tree of given graph. Parameters ---------- verbose: bool = True Wether to show a loading bar. Raises ------ ValueError If the given graph is not undirected. Returns ------- Numpy array of tuples of NodeIds forming the spanning tree. References ---------- This is the implementaiton of the algorithm presented in the paper A Fast, Parallel Spanning Tree Algorithm for Symmetric Multiprocessors by David A. Bader and Guojing Cong.""" pass
Returns set of edges forming the spanning tree of given graph.
Parameters
- verbose (bool = True): Wether to show a loading bar.
Raises
- ValueError: If the given graph is not undirected.
Returns
- Numpy array of tuples of NodeIds forming the spanning tree.
References
This is the implementaiton of the algorithm presented in the paper A Fast, Parallel Spanning Tree Algorithm for Symmetric Multiprocessors by David A. Bader and Guojing Cong.
View Source
def random_walks(self, walk_length: int, quantity: int, **kwargs) -> np.ndarray: """Return random walks done on the graph using Rust. Parameters ---------- walk_length: int Maximal length of the random walk. On graphs without traps, all walks have this length. quantity: int Number of nodes to sample. return_weight: float = 1.0 Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper. explore_weight: float = 1.0 Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper. change_edge_type_weight: float = 1.0 Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact. change_node_type_weight: float = 1.0 Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact. random_state: int = 42 random_state to use to reproduce the walks. iterations: int = 1 Number of cycles on the graphs to execute. dense_node_mapping: Dict[int, int] = None Mapping to use for converting sparse walk space into a dense space. This object can be created using the method available from graph called `get_dense_node_mapping` that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. max_neighbours: int = None Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk. Raises ------ TODO: Update raises Returns ------- List of list of walks containing the numeric IDs of nodes.""" pass
Return random walks done on the graph using Rust.
Parameters
- walk_length (int): Maximal length of the random walk. On graphs without traps, all walks have this length.
- quantity (int): Number of nodes to sample.
- return_weight (float = 1.0): Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper.
- explore_weight (float = 1.0): Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper.
- change_edge_type_weight (float = 1.0): Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact.
- change_node_type_weight (float = 1.0): Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact.
- random_state (int = 42): random_state to use to reproduce the walks.
- iterations (int = 1): Number of cycles on the graphs to execute.
- dense_node_mapping (Dict[int, int] = None):
Mapping to use for converting sparse walk space into a dense space.
This object can be created using the method available from graph
called
get_dense_node_mapping
that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. - max_neighbours (int = None): Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk.
Raises
- TODO (Update raises):
Returns
- List of list of walks containing the numeric IDs of nodes.
View Source
def complete_walks(self, walk_length: int, **kwargs) -> np.ndarray: """Return complete random walks done on the graph using Rust. Parameters ---------- walk_length: int Maximal length of the random walk. On graphs without traps, all walks have this length. return_weight: float = 1.0 Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper. explore_weight: float = 1.0 Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper. change_edge_type_weight: float = 1.0 Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact. change_node_type_weight: float = 1.0 Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact. random_state: int = 42 random_state to use to reproduce the walks. iterations: int = 1 Number of cycles on the graphs to execute. dense_node_mapping: Dict[int, int] = None Mapping to use for converting sparse walk space into a dense space. This object can be created using the method available from graph called `get_dense_node_mapping` that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. max_neighbours: int = None Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk. Raises ------ TODO: Update raises Returns ------- List of list of walks containing the numeric IDs of nodes.""" pass
Return complete random walks done on the graph using Rust.
Parameters
- walk_length (int): Maximal length of the random walk. On graphs without traps, all walks have this length.
- return_weight (float = 1.0): Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper.
- explore_weight (float = 1.0): Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper.
- change_edge_type_weight (float = 1.0): Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact.
- change_node_type_weight (float = 1.0): Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact.
- random_state (int = 42): random_state to use to reproduce the walks.
- iterations (int = 1): Number of cycles on the graphs to execute.
- dense_node_mapping (Dict[int, int] = None):
Mapping to use for converting sparse walk space into a dense space.
This object can be created using the method available from graph
called
get_dense_node_mapping
that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. - max_neighbours (int = None): Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk.
Raises
- TODO (Update raises):
Returns
- List of list of walks containing the numeric IDs of nodes.
View Source
def get_degree_centrality(self) -> np.ndarray: """Returns vector of unweighted degree centrality for all nodes""" pass
Returns vector of unweighted degree centrality for all nodes
View Source
def get_weighted_degree_centrality(self) -> np.ndarray: """Returns vector of weighted degree centrality for all nodes""" pass
Returns vector of weighted degree centrality for all nodes
View Source
def get_unchecked_closeness_centrality_from_node_id(self, node_id: int) -> float: """Return closeness centrality of the requested node. If the given node ID does not exist in the current graph the method will panic. Parameters ---------- node_id: int The node ID whose closeness centrality is to be computed. verbose: Optional[bool] Whether to show an indicative progress bar. Safety ------ If the given node ID does not exist in the graph the method will panic.""" pass
Return closeness centrality of the requested node.
If the given node ID does not exist in the current graph the method will panic.
Parameters
- node_id (int): The node ID whose closeness centrality is to be computed.
- verbose (Optional[bool]): Whether to show an indicative progress bar.
Safety
If the given node ID does not exist in the graph the method will panic.
View Source
def get_unchecked_weighted_closeness_centrality_from_node_id(self, node_id: int, use_edge_weights_as_probabilities: bool) -> float: """Return closeness centrality of the requested node. If the given node ID does not exist in the current graph the method will panic. Parameters ---------- node_id: int The node ID whose closeness centrality is to be computed. use_edge_weights_as_probabilities: bool Whether to treat the edge weights as probabilities. Safety ------ If the given node ID does not exist in the graph the method will panic.""" pass
Return closeness centrality of the requested node.
If the given node ID does not exist in the current graph the method will panic.
Parameters
- node_id (int): The node ID whose closeness centrality is to be computed.
- use_edge_weights_as_probabilities (bool): Whether to treat the edge weights as probabilities.
Safety
If the given node ID does not exist in the graph the method will panic.
View Source
def get_closeness_centrality(self, verbose: Optional[bool]) -> np.ndarray: """Return closeness centrality for all nodes. Parameters ---------- verbose: Optional[bool] Whether to show an indicative progress bar.""" pass
Return closeness centrality for all nodes.
Parameters
- verbose (Optional[bool]): Whether to show an indicative progress bar.
View Source
def get_weighted_closeness_centrality(self, use_edge_weights_as_probabilities: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Return closeness centrality for all nodes. Parameters ---------- use_edge_weights_as_probabilities: bool Whether to treat the edge weights as probabilities. verbose: Optional[bool] Whether to show an indicative progress bar. Raises ------- ValueError If the graph does not have weights. ValueError If the graph contains negative weights. ValueError If the user has asked for the weights to be treated as probabilities but the weights are not between 0 and 1.""" pass
Return closeness centrality for all nodes.
Parameters
- use_edge_weights_as_probabilities (bool): Whether to treat the edge weights as probabilities.
- verbose (Optional[bool]): Whether to show an indicative progress bar.
Raises
- ValueError: If the graph does not have weights.
- ValueError: If the graph contains negative weights.
- ValueError: If the user has asked for the weights to be treated as probabilities but the weights are not between 0 and 1.
View Source
def get_unchecked_harmonic_centrality_from_node_id(self, node_id: int) -> float: """Return harmonic centrality of the requested node. If the given node ID does not exist in the current graph the method will panic. Parameters ---------- node_id: int The node ID whose harmonic centrality is to be computed. Safety ------ If the given node ID does not exist in the graph the method will panic.""" pass
Return harmonic centrality of the requested node.
If the given node ID does not exist in the current graph the method will panic.
Parameters
- node_id (int): The node ID whose harmonic centrality is to be computed.
Safety
If the given node ID does not exist in the graph the method will panic.
View Source
def get_unchecked_weighted_harmonic_centrality_from_node_id(self, node_id: int, use_edge_weights_as_probabilities: bool) -> float: """Return harmonic centrality of the requested node. If the given node ID does not exist in the current graph the method will panic. Parameters ---------- node_id: int The node ID whose harmonic centrality is to be computed. use_edge_weights_as_probabilities: bool Whether to treat the edge weights as probabilities. Safety ------ If the given node ID does not exist in the graph the method will panic.""" pass
Return harmonic centrality of the requested node.
If the given node ID does not exist in the current graph the method will panic.
Parameters
- node_id (int): The node ID whose harmonic centrality is to be computed.
- use_edge_weights_as_probabilities (bool): Whether to treat the edge weights as probabilities.
Safety
If the given node ID does not exist in the graph the method will panic.
View Source
def get_harmonic_centrality(self, verbose: Optional[bool]) -> np.ndarray: """Return harmonic centrality for all nodes. Parameters ---------- verbose: Optional[bool] Whether to show an indicative progress bar.""" pass
Return harmonic centrality for all nodes.
Parameters
- verbose (Optional[bool]): Whether to show an indicative progress bar.
View Source
def get_weighted_harmonic_centrality(self, use_edge_weights_as_probabilities: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Return harmonic centrality for all nodes. Parameters ---------- use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. verbose: Optional[bool] Whether to show an indicative progress bar.""" pass
Return harmonic centrality for all nodes.
Parameters
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
- verbose (Optional[bool]): Whether to show an indicative progress bar.
View Source
def get_stress_centrality(self, normalize: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Returns vector of stress centrality for all nodes. Parameters ---------- normalize: Optional[bool] Whether to normalize the values. By default, it is false. verbose: Optional[bool] Whether to show a loading bar. By default, it is true.""" pass
Returns vector of stress centrality for all nodes.
Parameters
- normalize (Optional[bool]): Whether to normalize the values. By default, it is false.
- verbose (Optional[bool]): Whether to show a loading bar. By default, it is true.
View Source
def get_betweenness_centrality(self, normalize: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Returns vector of betweenness centrality for all nodes. Parameters ---------- normalize: Optional[bool] Whether to normalize the values. By default, it is false. verbose: Optional[bool] Whether to show a loading bar. By default, it is true.""" pass
Returns vector of betweenness centrality for all nodes.
Parameters
- normalize (Optional[bool]): Whether to normalize the values. By default, it is false.
- verbose (Optional[bool]): Whether to show a loading bar. By default, it is true.
View Source
def get_eigenvector_centrality(self, maximum_iterations_number: Optional[int], tollerance: Optional[float]) -> np.ndarray: """Returns vector with unweighted eigenvector centrality. Parameters ---------- maximum_iterations_number: Optional[int] The maximum number of iterations to consider. tollerance: Optional[float] The maximum error tollerance for convergence.""" pass
Returns vector with unweighted eigenvector centrality.
Parameters
- maximum_iterations_number (Optional[int]): The maximum number of iterations to consider.
- tollerance (Optional[float]): The maximum error tollerance for convergence.
View Source
def get_weighted_eigenvector_centrality(self, maximum_iterations_number: Optional[int], tollerance: Optional[float]) -> np.ndarray: """Returns vector with unweighted eigenvector centrality. Parameters ---------- maximum_iterations_number: Optional[int] The maximum number of iterations to consider. tollerance: Optional[float] The maximum error tollerance for convergence.""" pass
Returns vector with unweighted eigenvector centrality.
Parameters
- maximum_iterations_number (Optional[int]): The maximum number of iterations to consider.
- tollerance (Optional[float]): The maximum error tollerance for convergence.
View Source
def encode_edge(self, src: int, dst: int) -> int: """Return edge value corresponding to given node IDs. Parameters ---------- src: int The source node ID. dst: int The destination node ID.""" pass
Return edge value corresponding to given node IDs.
Parameters
- src (int): The source node ID.
- dst (int): The destination node ID.
View Source
def decode_edge(self, edge: int) -> Tuple[int, int]: """Returns source and destination nodes corresponding to given edge ID. Parameters ---------- edge: int The edge value to decode.""" pass
Returns source and destination nodes corresponding to given edge ID.
Parameters
- edge (int): The edge value to decode.
View Source
def get_max_encodable_edge_number(self) -> int: """Return maximum encodable edge number""" pass
Return maximum encodable edge number
View Source
def get_dense_binary_adjacency_matrix(self) -> np.ndarray: """Returns binary dense adjacency matrix. Beware of using this method on big graphs! It'll use all of your RAM!""" pass
Returns binary dense adjacency matrix.
Beware of using this method on big graphs! It'll use all of your RAM!
View Source
def get_dense_weighted_adjacency_matrix(self, weight: Optional[float]) -> np.ndarray: """Returns binary weighted adjacency matrix. Beware of using this method on big graphs! It'll use all of your RAM! Parameters ---------- weight: Optional[float] The weight value to use for absent edges. By default, `0.0`. Raises ------- ValueError If the graph does not have edge weights.""" pass
Returns binary weighted adjacency matrix.
Beware of using this method on big graphs! It'll use all of your RAM!
Parameters
- weight (Optional[float]):
The weight value to use for absent edges. By default,
0.0
.
Raises
- ValueError: If the graph does not have edge weights.
View Source
def get_unchecked_breadth_first_search_predecessors_parallel_from_node_id(self, src_node_id: int) -> ShortestPathsResultBFS: """Returns shortest path result for the BFS from given source node ID. Parameters ---------- src_node_id: int Root of the tree of minimum paths. Safety ------ If any of the given node ID does not exist in the graph the method will panic. TODO! Explore chains accelerations!""" pass
Returns shortest path result for the BFS from given source node ID.
Parameters
- src_node_id (int): Root of the tree of minimum paths.
Safety
If any of the given node ID does not exist in the graph the method will panic.
TODO! Explore chains accelerations!
View Source
def get_unchecked_breadth_first_search_distances_parallel_from_node_id(self, src_node_id: int) -> ShortestPathsResultBFS: """Returns shortest path result for the BFS from given source node ID. Parameters ---------- src_node_id: int Root of the tree of minimum paths. Safety ------ If any of the given node ID does not exist in the graph the method will panic. TODO! Explore chains accelerations!""" pass
Returns shortest path result for the BFS from given source node ID.
Parameters
- src_node_id (int): Root of the tree of minimum paths.
Safety
If any of the given node ID does not exist in the graph the method will panic.
TODO! Explore chains accelerations!
View Source
def get_unchecked_breadth_first_search_distances_sequential_from_node_id(self, src_node_id: int) -> ShortestPathsResultBFS: """Returns shortest path result for the BFS from given source node ID. Parameters ---------- src_node_id: int Root of the tree of minimum paths. Safety ------ If any of the given node ID does not exist in the graph the method will panic. TODO! Explore chains accelerations!""" pass
Returns shortest path result for the BFS from given source node ID.
Parameters
- src_node_id (int): Root of the tree of minimum paths.
Safety
If any of the given node ID does not exist in the graph the method will panic.
TODO! Explore chains accelerations!
View Source
def get_unchecked_breadth_first_search_from_node_ids(self, src_node_id: int, dst_node_id: Optional[int], compute_predecessors: Optional[bool], maximal_depth: Optional[int]) -> ShortestPathsResultBFS: """Returns vector of minimum paths distances and vector of nodes predecessors, if requested. Parameters ---------- src_node_id: int Root of the tree of minimum paths. maybe_dst_node_id: Optional[int] Optional target destination. If provided, Dijkstra will stop upon reaching this node. compute_predecessors: Optional[bool] Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal depth to execute the DFS for. Safety ------ If any of the given node IDs does not exist in the graph the method will panic. TODO! Explore chains accelerations!""" pass
Returns vector of minimum paths distances and vector of nodes predecessors, if requested.
Parameters
- src_node_id (int): Root of the tree of minimum paths.
- maybe_dst_node_id (Optional[int]): Optional target destination. If provided, Dijkstra will stop upon reaching this node.
- compute_predecessors (Optional[bool]): Whether to compute the vector of predecessors.
- maximal_depth (Optional[int]): The maximal depth to execute the DFS for.
Safety
If any of the given node IDs does not exist in the graph the method will panic.
TODO! Explore chains accelerations!
View Source
def get_unchecked_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, maximal_depth: Optional[int]) -> np.ndarray: """Returns minimum path node IDs and distance from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. maximal_depth: Optional[int] The maximal depth to execute the BFS for. Safety ------ If any of the given node IDs does not exist in the graph the method will panic. Raises ------- ValueError If the given node is a selfloop. ValueError If there is no path between the two given nodes.""" pass
Returns minimum path node IDs and distance from given node ids.
Parameters
- src_node_id (int): Source node ID.
- dst_node_id (int): Destination node ID.
- maximal_depth (Optional[int]): The maximal depth to execute the BFS for.
Safety
If any of the given node IDs does not exist in the graph the method will panic.
Raises
- ValueError: If the given node is a selfloop.
- ValueError: If there is no path between the two given nodes.
View Source
def get_unchecked_shortest_path_node_names_from_node_ids(self, src_node_id: int, dst_node_id: int, maximal_depth: Optional[int]) -> List[str]: """Returns minimum path node names from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. maximal_depth: Optional[int] The maximal depth to execute the BFS for. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass
Returns minimum path node names from given node ids.
Parameters
- src_node_id (int): Source node ID.
- dst_node_id (int): Destination node ID.
- maximal_depth (Optional[int]): The maximal depth to execute the BFS for.
Safety
If any of the given node IDs does not exist in the graph the method will panic.
View Source
def get_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, maximal_depth: Optional[int]) -> np.ndarray: """Returns minimum path node names from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. maximal_depth: Optional[int] The maximal depth to execute the BFS for. Raises ------- ValueError If any of the given node IDs do not exist in the current graph.""" pass
Returns minimum path node names from given node ids.
Parameters
- src_node_id (int): Source node ID.
- dst_node_id (int): Destination node ID.
- maximal_depth (Optional[int]): The maximal depth to execute the BFS for.
Raises
- ValueError: If any of the given node IDs do not exist in the current graph.
View Source
def get_shortest_path_node_ids_from_node_names(self, src_node_name: str, dst_node_name: str, maximal_depth: Optional[int]) -> np.ndarray: """Returns minimum path node names from given node names. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. maximal_depth: Optional[int] The maximal depth to execute the BFS for. Raises ------- ValueError If any of the given node names do not exist in the current graph.""" pass
Returns minimum path node names from given node names.
Parameters
- src_node_name (str): Source node name.
- dst_node_name (str): Destination node name.
- maximal_depth (Optional[int]): The maximal depth to execute the BFS for.
Raises
- ValueError: If any of the given node names do not exist in the current graph.
View Source
def get_shortest_path_node_names_from_node_names(self, src_node_name: str, dst_node_name: str, maximal_depth: Optional[int]) -> List[str]: """Returns minimum path node names from given node names. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. maximal_depth: Optional[int] The maximal depth to execute the BFS for. Raises ------- ValueError If any of the given node names do not exist in the current graph.""" pass
Returns minimum path node names from given node names.
Parameters
- src_node_name (str): Source node name.
- dst_node_name (str): Destination node name.
- maximal_depth (Optional[int]): The maximal depth to execute the BFS for.
Raises
- ValueError: If any of the given node names do not exist in the current graph.
View Source
def get_unchecked_k_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, k: int) -> List[List[int]]: """Return vector of the k minimum paths node IDs between given source node and destination node ID. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. k: int Number of paths to find. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass
Return vector of the k minimum paths node IDs between given source node and destination node ID.
Parameters
- src_node_id (int): Source node ID.
- dst_node_id (int): Destination node ID.
- k (int): Number of paths to find.
Safety
If any of the given node IDs does not exist in the graph the method will panic.
View Source
def get_k_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, k: int) -> List[List[int]]: """Return vector of the k minimum paths node IDs between given source node and destination node ID. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. maximal_depth: Optional[int] The maximal depth to execute the BFS for. k: int Number of paths to find. Raises ------- ValueError If any of the given node IDs does not exist in the graph.""" pass
Return vector of the k minimum paths node IDs between given source node and destination node ID.
Parameters
- src_node_id (int): Source node ID.
- dst_node_id (int): Destination node ID.
- maximal_depth (Optional[int]): The maximal depth to execute the BFS for.
- k (int): Number of paths to find.
Raises
- ValueError: If any of the given node IDs does not exist in the graph.
View Source
def get_k_shortest_path_node_ids_from_node_names(self, src_node_name: str, dst_node_name: str, k: int) -> List[List[int]]: """Return vector of the k minimum paths node IDs between given source node and destination node name. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. k: int Number of paths to find. Raises ------- ValueError If any of the given node names does not exist in the graph.""" pass
Return vector of the k minimum paths node IDs between given source node and destination node name.
Parameters
- src_node_name (str): Source node name.
- dst_node_name (str): Destination node name.
- k (int): Number of paths to find.
Raises
- ValueError: If any of the given node names does not exist in the graph.
View Source
def get_k_shortest_path_node_names_from_node_names(self, src_node_name: str, dst_node_name: str, k: int) -> List[List[str]]: """Return vector of the k minimum paths node names between given source node and destination node name. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. k: int Number of paths to find. Raises ------- ValueError If any of the given node names does not exist in the graph.""" pass
Return vector of the k minimum paths node names between given source node and destination node name.
Parameters
- src_node_name (str): Source node name.
- dst_node_name (str): Destination node name.
- k (int): Number of paths to find.
Raises
- ValueError: If any of the given node names does not exist in the graph.
View Source
def get_unchecked_eccentricity_and_most_distant_node_id_from_node_id(self, node_id: int) -> Tuple[int, int]: """Returns unweighted eccentricity of the given node. This method will panic if the given node ID does not exists in the graph. Parameters ---------- node_id: int Node for which to compute the eccentricity. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass
Returns unweighted eccentricity of the given node.
This method will panic if the given node ID does not exists in the graph.
Parameters
- node_id (int): Node for which to compute the eccentricity.
Safety
If any of the given node IDs does not exist in the graph the method will panic.
View Source
def get_unchecked_weighted_eccentricity_from_node_id(self, node_id: int, use_edge_weights_as_probabilities: Optional[bool]) -> float: """Returns weighted eccentricity of the given node. This method will panic if the given node ID does not exists in the graph. Parameters ---------- node_id: int Node for which to compute the eccentricity. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass
Returns weighted eccentricity of the given node.
This method will panic if the given node ID does not exists in the graph.
Parameters
- node_id (int): Node for which to compute the eccentricity.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
Safety
If any of the given node IDs does not exist in the graph the method will panic.
View Source
def get_eccentricity_and_most_distant_node_id_from_node_id(self, node_id: int) -> Tuple[int, int]: """Returns unweighted eccentricity of the given node ID. Parameters ---------- node_id: int Node for which to compute the eccentricity. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Raises ------- ValueError If the given node ID does not exist in the graph.""" pass
Returns unweighted eccentricity of the given node ID.
Parameters
- node_id (int): Node for which to compute the eccentricity.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
Raises
- ValueError: If the given node ID does not exist in the graph.
View Source
def get_weighted_eccentricity_from_node_id(self, node_id: int, use_edge_weights_as_probabilities: Optional[bool]) -> float: """Returns weighted eccentricity of the given node ID. Parameters ---------- node_id: int Node for which to compute the eccentricity. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Raises ------- ValueError If the given node ID does not exist in the graph. ValueError If weights are requested to be treated as probabilities but are not between 0 and 1. ValueError If the graph contains negative weights.""" pass
Returns weighted eccentricity of the given node ID.
Parameters
- node_id (int): Node for which to compute the eccentricity.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
Raises
- ValueError: If the given node ID does not exist in the graph.
- ValueError: If weights are requested to be treated as probabilities but are not between 0 and 1.
- ValueError: If the graph contains negative weights.
View Source
def get_eccentricity_from_node_name(self, node_name: str) -> int: """Returns unweighted eccentricity of the given node name. Parameters ---------- node_name: str Node for which to compute the eccentricity. Raises ------- ValueError If the given node name does not exist in the current graph instance.""" pass
Returns unweighted eccentricity of the given node name.
Parameters
- node_name (str): Node for which to compute the eccentricity.
Raises
- ValueError: If the given node name does not exist in the current graph instance.
View Source
def get_weighted_eccentricity_from_node_name(self, node_name: str, use_edge_weights_as_probabilities: Optional[bool]) -> float: """Returns weighted eccentricity of the given node name. Parameters ---------- node_name: str Node for which to compute the eccentricity. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Raises ------- ValueError If the given node name does not exist in the graph. ValueError If weights are requested to be treated as probabilities but are not between 0 and 1. ValueError If the graph contains negative weights.""" pass
Returns weighted eccentricity of the given node name.
Parameters
- node_name (str): Node for which to compute the eccentricity.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
Raises
- ValueError: If the given node name does not exist in the graph.
- ValueError: If weights are requested to be treated as probabilities but are not between 0 and 1.
- ValueError: If the graph contains negative weights.
View Source
def get_unchecked_dijkstra_from_node_ids(self, src_node_id: int, maybe_dst_node_id: Optional[int], maybe_dst_node_ids: Optional[List[int]], compute_predecessors: Optional[bool], maximal_depth: Optional[int], use_edge_weights_as_probabilities: Optional[bool]) -> ShortestPathsDjkstra: """Returns vector of minimum paths distances and vector of nodes predecessors, if requested. Parameters ---------- src_node_id: int Root of the tree of minimum paths. maybe_dst_node_id: Optional[int] Optional target destination. If provided, Dijkstra will stop upon reaching this node. maybe_dst_node_ids: Optional[List[int]] Optional target destinations. If provided, Dijkstra will stop upon reaching all of these nodes. compute_predecessors: bool Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass
Returns vector of minimum paths distances and vector of nodes predecessors, if requested.
Parameters
- src_node_id (int): Root of the tree of minimum paths.
- maybe_dst_node_id (Optional[int]): Optional target destination. If provided, Dijkstra will stop upon reaching this node.
- maybe_dst_node_ids (Optional[List[int]]): Optional target destinations. If provided, Dijkstra will stop upon reaching all of these nodes.
- compute_predecessors (bool): Whether to compute the vector of predecessors.
- maximal_depth (Optional[int]): The maximal number of iterations to execute Dijkstra for.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
Safety
If any of the given node IDs does not exist in the graph the method will panic.
View Source
def get_unchecked_weighted_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, use_edge_weights_as_probabilities: Optional[bool], maximal_depth: Optional[int]) -> Tuple[float, List[int]]: """Returns minimum path node IDs and distance from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass
Returns minimum path node IDs and distance from given node ids.
Parameters
- src_node_id (int): Source node ID.
- dst_node_id (int): Destination node ID.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
- maximal_depth (Optional[int]): The maximal number of iterations to execute Dijkstra for.
Safety
If any of the given node IDs does not exist in the graph the method will panic.
View Source
def get_unchecked_weighted_shortest_path_node_names_from_node_ids(self, src_node_id: int, dst_node_id: int, use_edge_weights_as_probabilities: Optional[bool], maximal_depth: Optional[int]) -> Tuple[float, List[str]]: """Returns minimum path node names from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. Safety ------ If any of the given node IDs does not exist in the graph the method will panic.""" pass
Returns minimum path node names from given node ids.
Parameters
- src_node_id (int): Source node ID.
- dst_node_id (int): Destination node ID.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
- maximal_depth (Optional[int]): The maximal number of iterations to execute Dijkstra for.
Safety
If any of the given node IDs does not exist in the graph the method will panic.
View Source
def get_weighted_shortest_path_node_ids_from_node_ids(self, src_node_id: int, dst_node_id: int, use_edge_weights_as_probabilities: Optional[bool], maximal_depth: Optional[int]) -> Tuple[float, List[int]]: """Returns minimum path node names from given node ids. Parameters ---------- src_node_id: int Source node ID. dst_node_id: int Destination node ID. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. Raises ------- ValueError If any of the given node IDs do not exist in the current graph.""" pass
Returns minimum path node names from given node ids.
Parameters
- src_node_id (int): Source node ID.
- dst_node_id (int): Destination node ID.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
- maximal_depth (Optional[int]): The maximal number of iterations to execute Dijkstra for.
Raises
- ValueError: If any of the given node IDs do not exist in the current graph.
View Source
def get_weighted_shortest_path_node_ids_from_node_names(self, src_node_name: str, dst_node_name: str, use_edge_weights_as_probabilities: Optional[bool], maximal_depth: Optional[int]) -> Tuple[float, List[int]]: """Returns minimum path node names from given node names. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. Raises ------- ValueError If any of the given node names do not exist in the current graph.""" pass
Returns minimum path node names from given node names.
Parameters
- src_node_name (str): Source node name.
- dst_node_name (str): Destination node name.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
- maximal_depth (Optional[int]): The maximal number of iterations to execute Dijkstra for.
Raises
- ValueError: If any of the given node names do not exist in the current graph.
View Source
def get_weighted_shortest_path_node_names_from_node_names(self, src_node_name: str, dst_node_name: str, use_edge_weights_as_probabilities: Optional[bool], maximal_depth: Optional[int]) -> Tuple[float, List[str]]: """Returns minimum path node names from given node names. Parameters ---------- src_node_name: str Source node name. dst_node_name: str Destination node name. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. maximal_depth: Optional[int] The maximal number of iterations to execute Dijkstra for. Raises ------- ValueError If any of the given node names do not exist in the current graph.""" pass
Returns minimum path node names from given node names.
Parameters
- src_node_name (str): Source node name.
- dst_node_name (str): Destination node name.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
- maximal_depth (Optional[int]): The maximal number of iterations to execute Dijkstra for.
Raises
- ValueError: If any of the given node names do not exist in the current graph.
View Source
def get_breadth_first_search_from_node_ids(self, src_node_id: int, dst_node_id: Optional[int], compute_predecessors: Optional[bool], maximal_depth: Optional[int]) -> ShortestPathsResultBFS: """Returns vector of minimum paths distances and vector of nodes predecessors from given source node ID and optional destination node ID. Parameters ---------- src_node_id: int Node ID root of the tree of minimum paths. compute_predecessors: Optional[bool] Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal number of iterations to execute the DFS for. Raises ------- ValueError If the given source node ID does not exist in the current graph. ValueError If the given optional destination node ID does not exist in the current graph.""" pass
Returns vector of minimum paths distances and vector of nodes predecessors from given source node ID and optional destination node ID.
Parameters
- src_node_id (int): Node ID root of the tree of minimum paths.
- compute_predecessors (Optional[bool]): Whether to compute the vector of predecessors.
- maximal_depth (Optional[int]): The maximal number of iterations to execute the DFS for.
Raises
- ValueError: If the given source node ID does not exist in the current graph.
- ValueError: If the given optional destination node ID does not exist in the current graph.
View Source
def get_dijkstra_from_node_ids(self, src_node_id: int, maybe_dst_node_id: Optional[int], maybe_dst_node_ids: Optional[List[int]], compute_predecessors: Optional[bool], maximal_depth: Optional[int], use_edge_weights_as_probabilities: Optional[bool]) -> ShortestPathsDjkstra: """Returns vector of minimum paths distances and vector of nodes predecessors from given source node ID and optional destination node ID. Parameters ---------- src_node_id: int Node ID root of the tree of minimum paths. maybe_dst_node_id: Optional[int] Optional target destination. If provided, Dijkstra will stop upon reaching this node. maybe_dst_node_ids: Optional[List[int]] Optional target destinations. If provided, Dijkstra will stop upon reaching all of these nodes. compute_predecessors: Optional[bool] Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal depth to execute the DFS for. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Raises ------- ValueError If the weights are to be used and the graph does not have weights. ValueError If the given source node ID does not exist in the current graph. ValueError If the given optional destination node ID does not exist in the current graph. ValueError If weights are requested to be treated as probabilities but are not between 0 and 1. ValueError If the graph contains negative weights.""" pass
Returns vector of minimum paths distances and vector of nodes predecessors from given source node ID and optional destination node ID.
Parameters
- src_node_id (int): Node ID root of the tree of minimum paths.
- maybe_dst_node_id (Optional[int]): Optional target destination. If provided, Dijkstra will stop upon reaching this node.
- maybe_dst_node_ids (Optional[List[int]]): Optional target destinations. If provided, Dijkstra will stop upon reaching all of these nodes.
- compute_predecessors (Optional[bool]): Whether to compute the vector of predecessors.
- maximal_depth (Optional[int]): The maximal depth to execute the DFS for.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
Raises
- ValueError: If the weights are to be used and the graph does not have weights.
- ValueError: If the given source node ID does not exist in the current graph.
- ValueError: If the given optional destination node ID does not exist in the current graph.
- ValueError: If weights are requested to be treated as probabilities but are not between 0 and 1.
- ValueError: If the graph contains negative weights.
View Source
def get_diameter_naive(self, ignore_infinity: Optional[bool], verbose: Optional[bool]) -> float: """Returns diameter of the graph using naive method. Note that there exists the non-naive method for undirected graphs and it is possible to implement a faster method for directed graphs but we still need to get to it, as it will require an updated succinct data structure. Parameters ---------- ignore_infinity: Optional[bool] Whether to ignore infinite distances, which are present when in the graph exist multiple components. verbose: Optional[bool] Whether to show a loading bar. Raises ------- ValueError If the graph does not contain nodes.""" pass
Returns diameter of the graph using naive method.
Note that there exists the non-naive method for undirected graphs and it is possible to implement a faster method for directed graphs but we still need to get to it, as it will require an updated succinct data structure.
Parameters
- ignore_infinity (Optional[bool]): Whether to ignore infinite distances, which are present when in the graph exist multiple components.
- verbose (Optional[bool]): Whether to show a loading bar.
Raises
- ValueError: If the graph does not contain nodes.
View Source
def get_diameter(self, ignore_infinity: Optional[bool], verbose: Optional[bool]) -> float: """Returns diameter of the graph. Parameters ---------- ignore_infinity: Optional[bool] Whether to ignore infinite distances, which are present when in the graph exist multiple components. verbose: Optional[bool] Whether to show a loading bar. Raises ------- ValueError If the graph does not contain nodes.""" pass
Returns diameter of the graph.
Parameters
- ignore_infinity (Optional[bool]): Whether to ignore infinite distances, which are present when in the graph exist multiple components.
- verbose (Optional[bool]): Whether to show a loading bar.
Raises
- ValueError: If the graph does not contain nodes.
View Source
def get_weighted_diameter_naive(self, ignore_infinity: Optional[bool], use_edge_weights_as_probabilities: Optional[bool], verbose: Optional[bool]) -> float: """Returns diameter of the graph using naive method. Note that there exists the non-naive method for undirected graphs and it is possible to implement a faster method for directed graphs but we still need to get to it, as it will require an updated succinct data structure. Parameters ---------- ignore_infinity: Optional[bool] Whether to ignore infinite distances, which are present when in the graph exist multiple components. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. verbose: Optional[bool] Whether to show a loading bar. Raises ------- ValueError If the graph does not contain nodes. ValueError If the graph does not have weights. ValueError If the graph contains negative weights. ValueError If the user has asked for the weights to be treated as probabilities but the weights are not between 0 and 1.""" pass
Returns diameter of the graph using naive method.
Note that there exists the non-naive method for undirected graphs and it is possible to implement a faster method for directed graphs but we still need to get to it, as it will require an updated succinct data structure.
Parameters
- ignore_infinity (Optional[bool]): Whether to ignore infinite distances, which are present when in the graph exist multiple components.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
- verbose (Optional[bool]): Whether to show a loading bar.
Raises
- ValueError: If the graph does not contain nodes.
- ValueError: If the graph does not have weights.
- ValueError: If the graph contains negative weights.
- ValueError: If the user has asked for the weights to be treated as probabilities but the weights are not between 0 and 1.
View Source
def get_breadth_first_search_from_node_names(self, src_node_name: str, dst_node_name: Optional[str], compute_predecessors: Optional[bool], maximal_depth: Optional[int]) -> ShortestPathsResultBFS: """Returns vector of minimum paths distances and vector of nodes predecessors from given source node name and optional destination node name. Parameters ---------- src_node_name: str Node name root of the tree of minimum paths. dst_node_name: Optional[str] Destination node name. compute_predecessors: Optional[bool] Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal depth to execute the DFS for. Raises ------- ValueError If the weights are to be used and the graph does not have weights. ValueError If the given source node name does not exist in the current graph. ValueError If the given optional destination node name does not exist in the current graph.""" pass
Returns vector of minimum paths distances and vector of nodes predecessors from given source node name and optional destination node name.
Parameters
- src_node_name (str): Node name root of the tree of minimum paths.
- dst_node_name (Optional[str]): Destination node name.
- compute_predecessors (Optional[bool]): Whether to compute the vector of predecessors.
- maximal_depth (Optional[int]): The maximal depth to execute the DFS for.
Raises
- ValueError: If the weights are to be used and the graph does not have weights.
- ValueError: If the given source node name does not exist in the current graph.
- ValueError: If the given optional destination node name does not exist in the current graph.
View Source
def get_dijkstra_from_node_names(self, src_node_name: str, maybe_dst_node_name: Optional[str], maybe_dst_node_names: Optional[List[str]], compute_predecessors: Optional[bool], maximal_depth: Optional[int], use_edge_weights_as_probabilities: Optional[bool]) -> ShortestPathsDjkstra: """Returns vector of minimum paths distances and vector of nodes predecessors from given source node name and optional destination node name. Parameters ---------- src_node_name: str Node name root of the tree of minimum paths. maybe_dst_node_name: Optional[str] Optional target destination node name. If provided, Dijkstra will stop upon reaching this node. maybe_dst_node_names: Optional[List[str]] Optional target destination node names. If provided, Dijkstra will stop upon reaching all of these nodes. compute_predecessors: Optional[bool] Whether to compute the vector of predecessors. maximal_depth: Optional[int] The maximal depth to execute the DFS for. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. Raises ------- ValueError If the weights are to be used and the graph does not have weights. ValueError If the given source node name does not exist in the current graph. ValueError If the given optional destination node name does not exist in the current graph.""" pass
Returns vector of minimum paths distances and vector of nodes predecessors from given source node name and optional destination node name.
Parameters
- src_node_name (str): Node name root of the tree of minimum paths.
- maybe_dst_node_name (Optional[str]): Optional target destination node name. If provided, Dijkstra will stop upon reaching this node.
- maybe_dst_node_names (Optional[List[str]]): Optional target destination node names. If provided, Dijkstra will stop upon reaching all of these nodes.
- compute_predecessors (Optional[bool]): Whether to compute the vector of predecessors.
- maximal_depth (Optional[int]): The maximal depth to execute the DFS for.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
Raises
- ValueError: If the weights are to be used and the graph does not have weights.
- ValueError: If the given source node name does not exist in the current graph.
- ValueError: If the given optional destination node name does not exist in the current graph.
View Source
def get_bipartite_edges(self, removed_existing_edges: Optional[bool], first_nodes_set: Optional[Set[str]], second_nodes_set: Optional[Set[str]], first_node_types_set: Optional[Set[str]], second_node_types_set: Optional[Set[str]]) -> np.ndarray: """Return vector of tuple of Node IDs that form the edges of the required bipartite graph. Parameters ---------- removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. first_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the first set of nodes of the graph. second_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the second set of nodes of the graph. first_node_types_set: Optional[Set[str]] Optional set of node types to create the first set of nodes of the graph. second_node_types_set: Optional[Set[str]] Optional set of node types to create the second set of nodes of the graph.""" pass
Return vector of tuple of Node IDs that form the edges of the required bipartite graph.
Parameters
- removed_existing_edges (Optional[bool]): Whether to filter out the existing edges. By default, true.
- first_nodes_set (Optional[Set[str]]): Optional set of nodes to use to create the first set of nodes of the graph.
- second_nodes_set (Optional[Set[str]]): Optional set of nodes to use to create the second set of nodes of the graph.
- first_node_types_set (Optional[Set[str]]): Optional set of node types to create the first set of nodes of the graph.
- second_node_types_set (Optional[Set[str]]): Optional set of node types to create the second set of nodes of the graph.
View Source
def get_bipartite_edge_names(self, removed_existing_edges: Optional[bool], first_nodes_set: Optional[Set[str]], second_nodes_set: Optional[Set[str]], first_node_types_set: Optional[Set[str]], second_node_types_set: Optional[Set[str]]) -> List[List[str]]: """Return vector of tuple of Node IDs that form the edges of the required bipartite graph. Parameters ---------- removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. first_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the first set of nodes of the graph. second_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the second set of nodes of the graph. first_node_types_set: Optional[Set[str]] Optional set of node types to create the first set of nodes of the graph. second_node_types_set: Optional[Set[str]] Optional set of node types to create the second set of nodes of the graph.""" pass
Return vector of tuple of Node IDs that form the edges of the required bipartite graph.
Parameters
- removed_existing_edges (Optional[bool]): Whether to filter out the existing edges. By default, true.
- first_nodes_set (Optional[Set[str]]): Optional set of nodes to use to create the first set of nodes of the graph.
- second_nodes_set (Optional[Set[str]]): Optional set of nodes to use to create the second set of nodes of the graph.
- first_node_types_set (Optional[Set[str]]): Optional set of node types to create the first set of nodes of the graph.
- second_node_types_set (Optional[Set[str]]): Optional set of node types to create the second set of nodes of the graph.
View Source
def get_star_edges(self, central_node: str, removed_existing_edges: Optional[bool], star_points_nodes_set: Optional[Set[str]], star_points_node_types_set: Optional[Set[str]]) -> np.ndarray: """Return vector of tuple of Node IDs that form the edges of the required star. Parameters ---------- central_node: str Name of the node to use as center of the star. removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. star_points_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the set of star points. star_points_node_types_set: Optional[Set[str]] Optional set of node types to create the set of star points.""" pass
Return vector of tuple of Node IDs that form the edges of the required star.
Parameters
- central_node (str): Name of the node to use as center of the star.
- removed_existing_edges (Optional[bool]): Whether to filter out the existing edges. By default, true.
- star_points_nodes_set (Optional[Set[str]]): Optional set of nodes to use to create the set of star points.
- star_points_node_types_set (Optional[Set[str]]): Optional set of node types to create the set of star points.
View Source
def get_star_edge_names(self, central_node: str, removed_existing_edges: Optional[bool], star_points_nodes_set: Optional[Set[str]], star_points_node_types_set: Optional[Set[str]]) -> List[List[str]]: """Return vector of tuple of Node names that form the edges of the required star. Parameters ---------- central_node: str Name of the node to use as center of the star. removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. star_points_nodes_set: Optional[Set[str]] Optional set of nodes to use to create the set of star points. star_points_node_types_set: Optional[Set[str]] Optional set of node types to create the set of star points.""" pass
Return vector of tuple of Node names that form the edges of the required star.
Parameters
- central_node (str): Name of the node to use as center of the star.
- removed_existing_edges (Optional[bool]): Whether to filter out the existing edges. By default, true.
- star_points_nodes_set (Optional[Set[str]]): Optional set of nodes to use to create the set of star points.
- star_points_node_types_set (Optional[Set[str]]): Optional set of node types to create the set of star points.
View Source
def get_clique_edges(self, directed: Optional[bool], allow_selfloops: Optional[bool], removed_existing_edges: Optional[bool], allow_node_type_set: Optional[Set[str]], allow_node_set: Optional[Set[str]]) -> np.ndarray: """Return vector of tuple of Node IDs that form the edges of the required clique. Parameters ---------- directed: Optional[bool] Whether to return the edges as directed or undirected. By default, equal to the graph. allow_selfloops: Optional[bool] Whether to allow self-loops in the clique. By default, equal to the graph. removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. allow_node_type_set: Optional[Set[str]] Node types to include in the clique. allow_node_set: Optional[Set[str]] Nodes to include i the clique.""" pass
Return vector of tuple of Node IDs that form the edges of the required clique.
Parameters
- directed (Optional[bool]): Whether to return the edges as directed or undirected. By default, equal to the graph.
- allow_selfloops (Optional[bool]): Whether to allow self-loops in the clique. By default, equal to the graph.
- removed_existing_edges (Optional[bool]): Whether to filter out the existing edges. By default, true.
- allow_node_type_set (Optional[Set[str]]): Node types to include in the clique.
- allow_node_set (Optional[Set[str]]): Nodes to include i the clique.
View Source
def get_clique_edge_names(self, directed: Optional[bool], allow_selfloops: Optional[bool], removed_existing_edges: Optional[bool], allow_node_type_set: Optional[Set[str]], allow_node_set: Optional[Set[str]]) -> List[List[str]]: """Return vector of tuple of Node names that form the edges of the required clique. Parameters ---------- directed: Optional[bool] Whether to return the edges as directed or undirected. By default, equal to the graph. allow_selfloops: Optional[bool] Whether to allow self-loops in the clique. By default, equal to the graph. removed_existing_edges: Optional[bool] Whether to filter out the existing edges. By default, true. allow_node_type_set: Optional[Set[str]] Node types to include in the clique. allow_node_set: Optional[Set[str]] Nodes to include i the clique.""" pass
Return vector of tuple of Node names that form the edges of the required clique.
Parameters
- directed (Optional[bool]): Whether to return the edges as directed or undirected. By default, equal to the graph.
- allow_selfloops (Optional[bool]): Whether to allow self-loops in the clique. By default, equal to the graph.
- removed_existing_edges (Optional[bool]): Whether to filter out the existing edges. By default, true.
- allow_node_type_set (Optional[Set[str]]): Node types to include in the clique.
- allow_node_set (Optional[Set[str]]): Nodes to include i the clique.
View Source
def get_unchecked_minimum_preferential_attachment(self) -> float: """Returns the minumum unweighted preferential attachment score. Safety ------ If the graph does not contain nodes, the return value will be undefined.""" pass
Returns the minumum unweighted preferential attachment score.
Safety
If the graph does not contain nodes, the return value will be undefined.
View Source
def get_unchecked_maximum_preferential_attachment(self) -> float: """Returns the maximum unweighted preferential attachment score. Safety ------ If the graph does not contain nodes, the return value will be undefined.""" pass
Returns the maximum unweighted preferential attachment score.
Safety
If the graph does not contain nodes, the return value will be undefined.
View Source
def get_unchecked_weighted_minimum_preferential_attachment(self) -> float: """Returns the minumum weighted preferential attachment score. Safety ------ If the graph does not contain nodes, the return value will be undefined.""" pass
Returns the minumum weighted preferential attachment score.
Safety
If the graph does not contain nodes, the return value will be undefined.
View Source
def get_unchecked_weighted_maximum_preferential_attachment(self) -> float: """Returns the maximum weighted preferential attachment score. Safety ------ If the graph does not contain nodes, the return value will be undefined.""" pass
Returns the maximum weighted preferential attachment score.
Safety
If the graph does not contain nodes, the return value will be undefined.
View Source
def get_unchecked_preferential_attachment_from_node_ids(self, source_node_id: int, destination_node_id: int, normalize: bool) -> float: """Returns the unweighted preferential attachment from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. normalize: bool Whether to normalize within 0 to 1. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass
Returns the unweighted preferential attachment from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
- normalize (bool): Whether to normalize within 0 to 1.
Safety
If either of the provided one and two node IDs are higher than the number of nodes in the graph.
View Source
def get_preferential_attachment_from_node_ids(self, source_node_id: int, destination_node_id: int, normalize: bool) -> float: """Returns the unweighted preferential attachment from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. normalize: bool Whether to normalize by the square of maximum degree. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass
Returns the unweighted preferential attachment from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
- normalize (bool): Whether to normalize by the square of maximum degree.
Raises
- ValueError: If either of the node IDs are higher than the number of nodes in the graph.
View Source
def get_preferential_attachment_from_node_names(self, first_node_name: str, second_node_name: str, normalize: bool) -> float: """Returns the unweighted preferential attachment from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. normalize: bool Whether to normalize by the square of maximum degree. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass
Returns the unweighted preferential attachment from the given node names.
Parameters
- first_node_name (str): Node name of the first node.
- second_node_name (str): Node name of the second node.
- normalize (bool): Whether to normalize by the square of maximum degree.
Raises
- ValueError: If either of the given node names do not exist in the current graph.
View Source
def get_unchecked_weighted_preferential_attachment_from_node_ids(self, source_node_id: int, destination_node_id: int, normalize: bool) -> float: """Returns the weighted preferential attachment from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. normalize: bool Whether to normalize within 0 to 1. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass
Returns the weighted preferential attachment from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
- normalize (bool): Whether to normalize within 0 to 1.
Safety
If either of the provided one and two node IDs are higher than the number of nodes in the graph.
View Source
def get_weighted_preferential_attachment_from_node_ids(self, source_node_id: int, destination_node_id: int, normalize: bool) -> float: """Returns the weighted preferential attachment from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. normalize: bool Whether to normalize by the square of maximum degree. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass
Returns the weighted preferential attachment from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
- normalize (bool): Whether to normalize by the square of maximum degree.
Raises
- ValueError: If either of the node IDs are higher than the number of nodes in the graph.
View Source
def get_weighted_preferential_attachment_from_node_names(self, first_node_name: str, second_node_name: str, normalize: bool) -> float: """Returns the weighted preferential attachment from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. normalize: bool Whether to normalize by the square of maximum degree. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass
Returns the weighted preferential attachment from the given node names.
Parameters
- first_node_name (str): Node name of the first node.
- second_node_name (str): Node name of the second node.
- normalize (bool): Whether to normalize by the square of maximum degree.
Raises
- ValueError: If either of the given node names do not exist in the current graph.
View Source
def get_unchecked_jaccard_coefficient_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the Jaccard index for the two given nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass
Returns the Jaccard index for the two given nodes from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
Safety
If either of the provided one and two node IDs are higher than the number of nodes in the graph.
View Source
def get_jaccard_coefficient_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the Jaccard index for the two given nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass
Returns the Jaccard index for the two given nodes from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
Raises
- ValueError: If either of the node IDs are higher than the number of nodes in the graph.
View Source
def get_jaccard_coefficient_from_node_names(self, first_node_name: str, second_node_name: str) -> float: """Returns the Jaccard index for the two given nodes from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass
Returns the Jaccard index for the two given nodes from the given node names.
Parameters
- first_node_name (str): Node name of the first node.
- second_node_name (str): Node name of the second node.
Raises
- ValueError: If either of the given node names do not exist in the current graph.
View Source
def get_unchecked_adamic_adar_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the Adamic/Adar Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass
Returns the Adamic/Adar Index for the given pair of nodes from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
Safety
If either of the provided one and two node IDs are higher than the number of nodes in the graph.
View Source
def get_adamic_adar_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the Adamic/Adar Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass
Returns the Adamic/Adar Index for the given pair of nodes from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
Raises
- ValueError: If either of the node IDs are higher than the number of nodes in the graph.
View Source
def get_adamic_adar_index_from_node_names(self, first_node_name: str, second_node_name: str) -> float: """Returns the Adamic/Adar Index for the given pair of nodes from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass
Returns the Adamic/Adar Index for the given pair of nodes from the given node names.
Parameters
- first_node_name (str): Node name of the first node.
- second_node_name (str): Node name of the second node.
Raises
- ValueError: If either of the given node names do not exist in the current graph.
View Source
def get_unchecked_resource_allocation_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the unweighted Resource Allocation Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass
Returns the unweighted Resource Allocation Index for the given pair of nodes from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
Safety
If either of the provided one and two node IDs are higher than the number of nodes in the graph.
View Source
def get_unchecked_weighted_resource_allocation_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the weighted Resource Allocation Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Safety ------ If either of the provided one and two node IDs are higher than the number of nodes in the graph.""" pass
Returns the weighted Resource Allocation Index for the given pair of nodes from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
Safety
If either of the provided one and two node IDs are higher than the number of nodes in the graph.
View Source
def get_resource_allocation_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the unweighted Resource Allocation Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass
Returns the unweighted Resource Allocation Index for the given pair of nodes from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
Raises
- ValueError: If either of the node IDs are higher than the number of nodes in the graph.
View Source
def get_resource_allocation_index_from_node_names(self, first_node_name: str, second_node_name: str) -> float: """Returns the unweighted Resource Allocation Index for the given pair of nodes from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass
Returns the unweighted Resource Allocation Index for the given pair of nodes from the given node names.
Parameters
- first_node_name (str): Node name of the first node.
- second_node_name (str): Node name of the second node.
Raises
- ValueError: If either of the given node names do not exist in the current graph.
View Source
def get_weighted_resource_allocation_index_from_node_ids(self, source_node_id: int, destination_node_id: int) -> float: """Returns the weighted Resource Allocation Index for the given pair of nodes from the given node IDs. Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. Raises ------- ValueError If either of the node IDs are higher than the number of nodes in the graph.""" pass
Returns the weighted Resource Allocation Index for the given pair of nodes from the given node IDs.
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
Raises
- ValueError: If either of the node IDs are higher than the number of nodes in the graph.
View Source
def get_weighted_resource_allocation_index_from_node_names(self, first_node_name: str, second_node_name: str) -> float: """Returns the weighted Resource Allocation Index for the given pair of nodes from the given node names. Parameters ---------- first_node_name: str Node name of the first node. second_node_name: str Node name of the second node. Raises ------- ValueError If either of the given node names do not exist in the current graph.""" pass
Returns the weighted Resource Allocation Index for the given pair of nodes from the given node names.
Parameters
- first_node_name (str): Node name of the first node.
- second_node_name (str): Node name of the second node.
Raises
- ValueError: If either of the given node names do not exist in the current graph.
View Source
def get_unchecked_all_edge_metrics_from_node_ids(self, source_node_id: int, destination_node_id: int, normalize: bool) -> np.ndarray: """Returns all the implemented edge metrics for the two given node IDs. Specifically, the returned values are: * Adamic Adar * Jaccard coefficient * Resource allocation index * Preferential attachment Parameters ---------- source_node_id: int Node ID of the first node. destination_node_id: int Node ID of the second node. normalize: bool Whether to normalize within 0 to 1. Safety ------ If the given node IDs do not exist in the graph this method will panic.""" pass
Returns all the implemented edge metrics for the two given node IDs.
Specifically, the returned values are:
- Adamic Adar
- Jaccard coefficient
- Resource allocation index
- Preferential attachment
Parameters
- source_node_id (int): Node ID of the first node.
- destination_node_id (int): Node ID of the second node.
- normalize (bool): Whether to normalize within 0 to 1.
Safety
If the given node IDs do not exist in the graph this method will panic.
View Source
def filter_from_ids(self, node_ids_to_keep: Optional[List[int]], node_ids_to_filter: Optional[List[int]], node_type_ids_to_keep: Optional[List[Optional[List[int]]]], node_type_ids_to_filter: Optional[List[Optional[List[int]]]], node_type_id_to_keep: Optional[List[Optional[int]]], node_type_id_to_filter: Optional[List[Optional[int]]], edge_ids_to_keep: Optional[List[int]], edge_ids_to_filter: Optional[List[int]], edge_node_ids_to_keep: Optional[List[Tuple[int, int]]], edge_node_ids_to_filter: Optional[List[Tuple[int, int]]], edge_type_ids_to_keep: Optional[List[Optional[int]]], edge_type_ids_to_filter: Optional[List[Optional[int]]], min_edge_weight: Optional[float], max_edge_weight: Optional[float], filter_singleton_nodes: Optional[bool], filter_singleton_nodes_with_selfloop: Optional[bool], filter_selfloops: Optional[bool], filter_parallel_edges: Optional[bool]) -> Graph: """Returns a **NEW** Graph that does not have the required attributes. Parameters ---------- node_ids_to_keep: Optional[List[int]] List of node IDs to keep during filtering. node_ids_to_filter: Optional[List[int]] List of node IDs to remove during filtering. node_type_ids_to_keep: Optional[List[Optional[List[int]]]] List of node type IDs to keep during filtering. The node types must match entirely the given node types vector provided. node_type_ids_to_filter: Optional[List[Optional[List[int]]]] List of node type IDs to remove during filtering. The node types must match entirely the given node types vector provided. node_type_id_to_keep: Optional[List[Optional[int]]] List of node type IDs to keep during filtering. Any of node types must match with one of the node types given. node_type_id_to_filter: Optional[List[Optional[int]]] List of node type IDs to remove during filtering. Any of node types must match with one of the node types given. edge_ids_to_keep: Optional[List[int]] List of edge IDs to keep during filtering. edge_ids_to_filter: Optional[List[int]] List of edge IDs to remove during filtering. edge_node_ids_to_keep: Optional[List[Tuple[int, int]]] List of tuple of node IDs to keep during filtering. edge_node_ids_to_filter: Optional[List[Tuple[int, int]]] List of tuple of node IDs to remove during filtering. edge_type_ids_to_keep: Optional[List[Optional[int]]] List of edge type IDs to keep during filtering. edge_type_ids_to_filter: Optional[List[Optional[int]]] List of edge type IDs to remove during filtering. min_edge_weight: Optional[float] Minimum edge weight. Values lower than this are removed. max_edge_weight: Optional[float] Maximum edge weight. Values higher than this are removed. filter_singleton_nodes: Optional[bool] Whether to filter out singleton nodes. filter_singleton_nodes_with_selfloop: Optional[bool] Whether to filter out singleton nodes with selfloops. filter_selfloops: Optional[bool] Whether to filter out selfloops. filter_parallel_edges: Optional[bool] Whether to filter out parallel edges. verbose: Optional[bool] Whether to show loading bar while building the graphs.""" pass
Returns a NEW Graph that does not have the required attributes.
Parameters
- node_ids_to_keep (Optional[List[int]]): List of node IDs to keep during filtering.
- node_ids_to_filter (Optional[List[int]]): List of node IDs to remove during filtering.
- node_type_ids_to_keep (Optional[List[Optional[List[int]]]]): List of node type IDs to keep during filtering. The node types must match entirely the given node types vector provided.
- node_type_ids_to_filter (Optional[List[Optional[List[int]]]]): List of node type IDs to remove during filtering. The node types must match entirely the given node types vector provided.
- node_type_id_to_keep (Optional[List[Optional[int]]]): List of node type IDs to keep during filtering. Any of node types must match with one of the node types given.
- node_type_id_to_filter (Optional[List[Optional[int]]]): List of node type IDs to remove during filtering. Any of node types must match with one of the node types given.
- edge_ids_to_keep (Optional[List[int]]): List of edge IDs to keep during filtering.
- edge_ids_to_filter (Optional[List[int]]): List of edge IDs to remove during filtering.
- edge_node_ids_to_keep (Optional[List[Tuple[int, int]]]): List of tuple of node IDs to keep during filtering.
- edge_node_ids_to_filter (Optional[List[Tuple[int, int]]]): List of tuple of node IDs to remove during filtering.
- edge_type_ids_to_keep (Optional[List[Optional[int]]]): List of edge type IDs to keep during filtering.
- edge_type_ids_to_filter (Optional[List[Optional[int]]]): List of edge type IDs to remove during filtering.
- min_edge_weight (Optional[float]): Minimum edge weight. Values lower than this are removed.
- max_edge_weight (Optional[float]): Maximum edge weight. Values higher than this are removed.
- filter_singleton_nodes (Optional[bool]): Whether to filter out singleton nodes.
- filter_singleton_nodes_with_selfloop (Optional[bool]): Whether to filter out singleton nodes with selfloops.
- filter_selfloops (Optional[bool]): Whether to filter out selfloops.
- filter_parallel_edges (Optional[bool]): Whether to filter out parallel edges.
- verbose (Optional[bool]): Whether to show loading bar while building the graphs.
View Source
def filter_from_names(self, node_names_to_keep: Optional[List[str]], node_names_to_filter: Optional[List[str]], node_type_names_to_keep: Optional[List[Optional[List[str]]]], node_type_names_to_filter: Optional[List[Optional[List[str]]]], node_type_name_to_keep: Optional[List[Optional[str]]], node_type_name_to_filter: Optional[List[Optional[str]]], edge_node_names_to_keep: Optional[List[Tuple[str, str]]], edge_node_names_to_filter: Optional[List[Tuple[str, str]]], edge_type_names_to_keep: Optional[List[Optional[str]]], edge_type_names_to_filter: Optional[List[Optional[str]]], min_edge_weight: Optional[float], max_edge_weight: Optional[float], filter_singleton_nodes: Optional[bool], filter_singleton_nodes_with_selfloop: Optional[bool], filter_selfloops: Optional[bool], filter_parallel_edges: Optional[bool]) -> Graph: """Returns a **NEW** Graph that does not have the required attributes. Parameters ---------- node_names_to_keep: Optional[List[str]] List of node names to keep during filtering. node_names_to_filter: Optional[List[str]] List of node names to remove during filtering. node_type_names_to_keep: Optional[List[Optional[List[str]]]] List of node type names to keep during filtering. The node types must match entirely the given node types vector provided. node_type_names_to_filter: Optional[List[Optional[List[str]]]] List of node type names to remove during filtering. The node types must match entirely the given node types vector provided. node_type_name_to_keep: Optional[List[Optional[str]]] List of node type name to keep during filtering. Any of node types must match with one of the node types given. node_type_name_to_filter: Optional[List[Optional[str]]] List of node type name to remove during filtering. Any of node types must match with one of the node types given. edge_node_names_to_keep: Optional[List[Tuple[str, str]]] List of tuple of node names to keep during filtering. edge_node_names_to_filter: Optional[List[Tuple[str, str]]] List of tuple of node names to remove during filtering. edge_type_names_to_keep: Optional[List[Optional[str]]] List of edge type names to keep during filtering. edge_type_names_to_filter: Optional[List[Optional[str]]] List of edge type names to remove during filtering. min_edge_weight: Optional[float] Minimum edge weight. Values lower than this are removed. max_edge_weight: Optional[float] Maximum edge weight. Values higher than this are removed. filter_singleton_nodes: Optional[bool] Whether to filter out singletons. filter_singleton_nodes_with_selfloop: Optional[bool] Whether to filter out singleton nodes with selfloops. filter_selfloops: Optional[bool] Whether to filter out selfloops. filter_parallel_edges: Optional[bool] Whether to filter out parallel edges. verbose: Optional[bool] Whether to show loading bar while building the graphs.""" pass
Returns a NEW Graph that does not have the required attributes.
Parameters
- node_names_to_keep (Optional[List[str]]): List of node names to keep during filtering.
- node_names_to_filter (Optional[List[str]]): List of node names to remove during filtering.
- node_type_names_to_keep (Optional[List[Optional[List[str]]]]): List of node type names to keep during filtering. The node types must match entirely the given node types vector provided.
- node_type_names_to_filter (Optional[List[Optional[List[str]]]]): List of node type names to remove during filtering. The node types must match entirely the given node types vector provided.
- node_type_name_to_keep (Optional[List[Optional[str]]]): List of node type name to keep during filtering. Any of node types must match with one of the node types given.
- node_type_name_to_filter (Optional[List[Optional[str]]]): List of node type name to remove during filtering. Any of node types must match with one of the node types given.
- edge_node_names_to_keep (Optional[List[Tuple[str, str]]]): List of tuple of node names to keep during filtering.
- edge_node_names_to_filter (Optional[List[Tuple[str, str]]]): List of tuple of node names to remove during filtering.
- edge_type_names_to_keep (Optional[List[Optional[str]]]): List of edge type names to keep during filtering.
- edge_type_names_to_filter (Optional[List[Optional[str]]]): List of edge type names to remove during filtering.
- min_edge_weight (Optional[float]): Minimum edge weight. Values lower than this are removed.
- max_edge_weight (Optional[float]): Maximum edge weight. Values higher than this are removed.
- filter_singleton_nodes (Optional[bool]): Whether to filter out singletons.
- filter_singleton_nodes_with_selfloop (Optional[bool]): Whether to filter out singleton nodes with selfloops.
- filter_selfloops (Optional[bool]): Whether to filter out selfloops.
- filter_parallel_edges (Optional[bool]): Whether to filter out parallel edges.
- verbose (Optional[bool]): Whether to show loading bar while building the graphs.
View Source
def drop_unknown_node_types(self) -> Graph: """Returns new graph without unknown node types and relative nodes. Note that this method will remove ALL nodes labeled with unknown node type!""" pass
Returns new graph without unknown node types and relative nodes.
Note that this method will remove ALL nodes labeled with unknown node type!
View Source
def drop_unknown_edge_types(self) -> Graph: """Returns new graph without unknown edge types and relative edges. Note that this method will remove ALL edges labeled with unknown edge type!""" pass
Returns new graph without unknown edge types and relative edges.
Note that this method will remove ALL edges labeled with unknown edge type!
View Source
def drop_singleton_nodes(self) -> Graph: """Returns new graph without singleton nodes. A node is singleton when does not have neither incoming or outgoing edges.""" pass
Returns new graph without singleton nodes.
A node is singleton when does not have neither incoming or outgoing edges.
View Source
def drop_singleton_nodes_with_selfloops(self) -> Graph: """Returns new graph without singleton nodes with selfloops. A node is singleton with selfloop when does not have neither incoming or outgoing edges.""" pass
Returns new graph without singleton nodes with selfloops.
A node is singleton with selfloop when does not have neither incoming or outgoing edges.
View Source
def drop_disconnected_nodes(self) -> Graph: """Returns new graph without disconnected nodes. A disconnected node is a node with no connection to any other node.""" pass
Returns new graph without disconnected nodes.
A disconnected node is a node with no connection to any other node.
View Source
def drop_selfloops(self) -> Graph: """Returns new graph without selfloops.""" pass
Returns new graph without selfloops.
View Source
def drop_parallel_edges(self) -> Graph: """Returns new graph without parallel edges""" pass
Returns new graph without parallel edges
View Source
@staticmethod def from_csv(node_type_path: Optional[str], node_type_list_separator: Optional[str], node_types_column_number: Optional[int], node_types_column: Optional[str], node_types_ids_column_number: Optional[int], node_types_ids_column: Optional[str], node_types_number: Optional[int], numeric_node_type_ids: Optional[bool], minimum_node_type_id: Optional[int], node_type_list_header: Optional[bool], node_type_list_rows_to_skip: Optional[int], node_type_list_is_correct: Optional[bool], node_type_list_max_rows_number: Optional[int], node_type_list_comment_symbol: Optional[str], load_node_type_list_in_parallel: Optional[bool], node_path: Optional[str], node_list_separator: Optional[str], node_list_header: Optional[bool], node_list_rows_to_skip: Optional[int], node_list_is_correct: Optional[bool], node_list_max_rows_number: Optional[int], node_list_comment_symbol: Optional[str], default_node_type: Optional[str], nodes_column_number: Optional[int], nodes_column: Optional[str], node_types_separator: Optional[str], node_list_node_types_column_number: Optional[int], node_list_node_types_column: Optional[str], node_ids_column: Optional[str], node_ids_column_number: Optional[int], number_of_nodes: Optional[int], minimum_node_id: Optional[int], numeric_node_ids: Optional[bool], node_list_numeric_node_type_ids: Optional[bool], skip_node_types_if_unavailable: Optional[bool], load_node_list_in_parallel: Optional[bool], edge_type_path: Optional[str], edge_types_column_number: Optional[int], edge_types_column: Optional[str], edge_types_ids_column_number: Optional[int], edge_types_ids_column: Optional[str], edge_types_number: Optional[int], numeric_edge_type_ids: Optional[bool], minimum_edge_type_id: Optional[int], edge_type_list_separator: Optional[str], edge_type_list_header: Optional[bool], edge_type_list_rows_to_skip: Optional[int], edge_type_list_is_correct: Optional[bool], edge_type_list_max_rows_number: Optional[int], edge_type_list_comment_symbol: Optional[str], load_edge_type_list_in_parallel: Optional[bool], edge_path: Optional[str], edge_list_separator: Optional[str], edge_list_header: Optional[bool], edge_list_rows_to_skip: Optional[int], sources_column_number: Optional[int], sources_column: Optional[str], destinations_column_number: Optional[int], destinations_column: Optional[str], edge_list_edge_types_column_number: Optional[int], edge_list_edge_types_column: Optional[str], default_edge_type: Optional[str], weights_column_number: Optional[int], weights_column: Optional[str], default_weight: Optional[float], edge_ids_column: Optional[str], edge_ids_column_number: Optional[int], edge_list_numeric_edge_type_ids: Optional[bool], edge_list_numeric_node_ids: Optional[bool], skip_weights_if_unavailable: Optional[bool], skip_edge_types_if_unavailable: Optional[bool], edge_list_is_complete: Optional[bool], edge_list_may_contain_duplicates: Optional[bool], edge_list_is_sorted: Optional[bool], edge_list_is_correct: Optional[bool], edge_list_max_rows_number: Optional[int], edge_list_comment_symbol: Optional[str], edges_number: Optional[int], load_edge_list_in_parallel: Optional[bool], verbose: Optional[bool], may_have_singletons: Optional[bool], may_have_singleton_with_selfloops: Optional[bool], directed: bool, name: Optional[str]) -> Graph: """Return graph renderized from given CSVs or TSVs-like files. Parameters ---------- node_type_path: Optional[str] The path to the file with the unique node type names. node_type_list_separator: Optional[str] The separator to use for the node types file. Note that if this is not provided, one will be automatically detected among the following`: comma, semi-column, tab and space. node_types_column_number: Optional[int] The number of the column of the node types file from where to load the node types. node_types_column: Optional[str] The name of the column of the node types file from where to load the node types. node_types_number: Optional[int] The number of the unique node types. This will be used in order to allocate the correct size for the data structure. numeric_node_type_ids: Optional[bool] Whether the node type names should be loaded as numeric values, i.e. casted from string to a numeric representation. minimum_node_type_id: Optional[int] The minimum node type ID to be used when using numeric node type IDs. node_type_list_header: Optional[bool] Whether the node type file has an header. node_type_list_rows_to_skip: Optional[int] The number of lines to skip in the node types file`: the header is already skipped if it has been specified that the file has an header. node_type_list_is_correct: Optional[bool] Whether the node types file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash. node_type_list_max_rows_number: Optional[int] The maximum number of lines to be loaded from the node types file. node_type_list_comment_symbol: Optional[str] The comment symbol to skip lines in the node types file. Lines starting with this symbol will be skipped. load_node_type_list_in_parallel: Optional[bool] Whether to load the node type list in parallel. Note that when loading in parallel, the internal order of the node type IDs may result changed across different iterations. We are working to get this to be stable. node_path: Optional[str] The path to the file with the unique node names. node_list_separator: Optional[str] The separator to use for the nodes file. Note that if this is not provided, one will be automatically detected among the following`: comma, semi-column, tab and space. node_list_header: Optional[bool] Whether the nodes file has an header. node_list_rows_to_skip: Optional[int] Number of rows to skip in the node list file. node_list_is_correct: Optional[bool] Whether the nodes file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash. node_list_max_rows_number: Optional[int] The maximum number of lines to be loaded from the nodes file. node_list_comment_symbol: Optional[str] The comment symbol to skip lines in the nodes file. Lines starting with this symbol will be skipped. default_node_type: Optional[str] The node type to be used when the node type for a given node in the node file is None. nodes_column_number: Optional[int] The number of the column of the node file from where to load the node names. nodes_column: Optional[str] The name of the column of the node file from where to load the node names. node_types_separator: Optional[str] The node types separator. node_list_node_types_column_number: Optional[int] The number of the column of the node file from where to load the node types. node_list_node_types_column: Optional[str] The name of the column of the node file from where to load the node types. node_ids_column: Optional[str] The name of the column of the node file from where to load the node IDs. node_ids_column_number: Optional[int] The number of the column of the node file from where to load the node IDs number_of_nodes: Optional[int] The expected number of nodes. Note that this must be the EXACT number of nodes in the graph. minimum_node_id: Optional[int] The minimum node ID to be used, when loading the node IDs as numerical. numeric_node_ids: Optional[bool] Whether to load the numeric node IDs as numeric. node_list_numeric_node_type_ids: Optional[bool] Whether to load the node types IDs in the node file to be numeric. skip_node_types_if_unavailable: Optional[bool] Whether to skip the node types without raising an error if these are unavailable. load_node_list_in_parallel: Optional[bool] Whether to load the node list in parallel. When loading in parallel, without node IDs, the nodes may not be loaded in a deterministic order. edge_type_path: Optional[str] The path to the file with the unique edge type names. edge_types_column_number: Optional[int] The number of the column of the edge types file from where to load the edge types. edge_types_column: Optional[str] The name of the column of the edge types file from where to load the edge types. edge_types_number: Optional[int] The number of the unique edge types. This will be used in order to allocate the correct size for the data structure. numeric_edge_type_ids: Optional[bool] Whether the edge type names should be loaded as numeric values, i.e. casted from string to a numeric representation. minimum_edge_type_id: Optional[int] The minimum edge type ID to be used when using numeric edge type IDs. edge_type_list_separator: Optional[str] The separator to use for the edge type list. Note that, if None is provided, one will be attempted to be detected automatically between ';', ',', tab or space. edge_type_list_header: Optional[bool] Whether the edge type file has an header. edge_type_list_rows_to_skip: Optional[int] Number of rows to skip in the edge type list file. edge_type_list_is_correct: Optional[bool] Whether the edge types file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash. edge_type_list_max_rows_number: Optional[int] The maximum number of lines to be loaded from the edge types file. edge_type_list_comment_symbol: Optional[str] The comment symbol to skip lines in the edge types file. Lines starting with this symbol will be skipped. load_edge_type_list_in_parallel: Optional[bool] Whether to load the edge type list in parallel. When loading in parallel, without edge type IDs, the edge types may not be loaded in a deterministic order. edge_path: Optional[str] The path to the file with the edge list. edge_list_separator: Optional[str] The separator to use for the edge list. Note that, if None is provided, one will be attempted to be detected automatically between ';', ',', tab or space. edge_list_header: Optional[bool] Whether the edges file has an header. edge_list_rows_to_skip: Optional[int] Number of rows to skip in the edge list file. sources_column_number: Optional[int] The number of the column of the edges file from where to load the source nodes. sources_column: Optional[str] The name of the column of the edges file from where to load the source nodes. destinations_column_number: Optional[int] The number of the column of the edges file from where to load the destinaton nodes. destinations_column: Optional[str] The name of the column of the edges file from where to load the destinaton nodes. edge_list_edge_types_column_number: Optional[int] The number of the column of the edges file from where to load the edge types. edge_list_edge_types_column: Optional[str] The name of the column of the edges file from where to load the edge types. default_edge_type: Optional[str] The edge type to be used when the edge type for a given edge in the edge file is None. weights_column_number: Optional[int] The number of the column of the edges file from where to load the edge weights. weights_column: Optional[str] The name of the column of the edges file from where to load the edge weights. default_weight: Optional[float] The edge weight to be used when the edge weight for a given edge in the edge file is None. edge_ids_column: Optional[str] The name of the column of the edges file from where to load the edge IDs. edge_ids_column_number: Optional[int] The number of the column of the edges file from where to load the edge IDs. edge_list_numeric_edge_type_ids: Optional[bool] Whether to load the edge type IDs as numeric from the edge list. edge_list_numeric_node_ids: Optional[bool] Whether to load the edge node IDs as numeric from the edge list. skip_weights_if_unavailable: Optional[bool] Whether to skip the weights without raising an error if these are unavailable. skip_edge_types_if_unavailable: Optional[bool] Whether to skip the edge types without raising an error if these are unavailable. edge_list_is_complete: Optional[bool] Whether to consider the edge list as complete, i.e. the edges are presented in both directions when loading an undirected graph. edge_list_may_contain_duplicates: Optional[bool] Whether the edge list may contain duplicates. If the edge list surely DOES NOT contain duplicates, a validation step may be skipped. By default, it is assumed that the edge list may contain duplicates. edge_list_is_sorted: Optional[bool] Whether the edge list is sorted. Note that a sorted edge list has the minimal memory peak, but requires the nodes number and the edges number. edge_list_is_correct: Optional[bool] Whether the edges file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash. edge_list_max_rows_number: Optional[int] The maximum number of lines to be loaded from the edges file. edge_list_comment_symbol: Optional[str] The comment symbol to skip lines in the edges file. Lines starting with this symbol will be skipped. edges_number: Optional[int] The expected number of edges. Note that this must be the EXACT number of edges in the graph. load_edge_list_in_parallel: Optional[bool] Whether to load the edge list in parallel. Note that, if the edge IDs indices are not given, it is NOT possible to load a sorted edge list. Similarly, when loading in parallel, without edge IDs, the edges may not be loaded in a deterministic order. verbose: Optional[bool] Whether to show a loading bar while reading the files. Note that, if parallel loading is enabled, loading bars will not be showed because they are a synchronization bottleneck. may_have_singletons: Optional[bool] Whether the graph may be expected to have singleton nodes. If it is said that it surely DOES NOT have any, it will allow for some speedups and lower mempry peaks. may_have_singleton_with_selfloops: Optional[bool] Whether the graph may be expected to have singleton nodes with selfloops. If it is said that it surely DOES NOT have any, it will allow for some speedups and lower mempry peaks. directed: bool Whether to load the graph as directed or undirected. name: Optional[str] The name of the graph to be loaded.""" pass
Return graph renderized from given CSVs or TSVs-like files.
Parameters
- node_type_path (Optional[str]): The path to the file with the unique node type names.
- node_type_list_separator (Optional[str]): The separator to use for the node types file. Note that if this is not provided, one will be automatically detected among the following`: comma, semi-column, tab and space.
- node_types_column_number (Optional[int]): The number of the column of the node types file from where to load the node types.
- node_types_column (Optional[str]): The name of the column of the node types file from where to load the node types.
- node_types_number (Optional[int]): The number of the unique node types. This will be used in order to allocate the correct size for the data structure.
- numeric_node_type_ids (Optional[bool]): Whether the node type names should be loaded as numeric values, i.e. casted from string to a numeric representation.
- minimum_node_type_id (Optional[int]): The minimum node type ID to be used when using numeric node type IDs.
- node_type_list_header (Optional[bool]): Whether the node type file has an header.
- node_type_list_rows_to_skip (Optional[int]): The number of lines to skip in the node types file`: the header is already skipped if it has been specified that the file has an header.
- node_type_list_is_correct (Optional[bool]): Whether the node types file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash.
- node_type_list_max_rows_number (Optional[int]): The maximum number of lines to be loaded from the node types file.
- node_type_list_comment_symbol (Optional[str]): The comment symbol to skip lines in the node types file. Lines starting with this symbol will be skipped.
- load_node_type_list_in_parallel (Optional[bool]): Whether to load the node type list in parallel. Note that when loading in parallel, the internal order of the node type IDs may result changed across different iterations. We are working to get this to be stable.
- node_path (Optional[str]): The path to the file with the unique node names.
- node_list_separator (Optional[str]): The separator to use for the nodes file. Note that if this is not provided, one will be automatically detected among the following`: comma, semi-column, tab and space.
- node_list_header (Optional[bool]): Whether the nodes file has an header.
- node_list_rows_to_skip (Optional[int]): Number of rows to skip in the node list file.
- node_list_is_correct (Optional[bool]): Whether the nodes file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash.
- node_list_max_rows_number (Optional[int]): The maximum number of lines to be loaded from the nodes file.
- node_list_comment_symbol (Optional[str]): The comment symbol to skip lines in the nodes file. Lines starting with this symbol will be skipped.
- default_node_type (Optional[str]): The node type to be used when the node type for a given node in the node file is None.
- nodes_column_number (Optional[int]): The number of the column of the node file from where to load the node names.
- nodes_column (Optional[str]): The name of the column of the node file from where to load the node names.
- node_types_separator (Optional[str]): The node types separator.
- node_list_node_types_column_number (Optional[int]): The number of the column of the node file from where to load the node types.
- node_list_node_types_column (Optional[str]): The name of the column of the node file from where to load the node types.
- node_ids_column (Optional[str]): The name of the column of the node file from where to load the node IDs.
- node_ids_column_number (Optional[int]): The number of the column of the node file from where to load the node IDs
- number_of_nodes (Optional[int]): The expected number of nodes. Note that this must be the EXACT number of nodes in the graph.
- minimum_node_id (Optional[int]): The minimum node ID to be used, when loading the node IDs as numerical.
- numeric_node_ids (Optional[bool]): Whether to load the numeric node IDs as numeric.
- node_list_numeric_node_type_ids (Optional[bool]): Whether to load the node types IDs in the node file to be numeric.
- skip_node_types_if_unavailable (Optional[bool]): Whether to skip the node types without raising an error if these are unavailable.
- load_node_list_in_parallel (Optional[bool]): Whether to load the node list in parallel. When loading in parallel, without node IDs, the nodes may not be loaded in a deterministic order.
- edge_type_path (Optional[str]): The path to the file with the unique edge type names.
- edge_types_column_number (Optional[int]): The number of the column of the edge types file from where to load the edge types.
- edge_types_column (Optional[str]): The name of the column of the edge types file from where to load the edge types.
- edge_types_number (Optional[int]): The number of the unique edge types. This will be used in order to allocate the correct size for the data structure.
- numeric_edge_type_ids (Optional[bool]): Whether the edge type names should be loaded as numeric values, i.e. casted from string to a numeric representation.
- minimum_edge_type_id (Optional[int]): The minimum edge type ID to be used when using numeric edge type IDs.
- edge_type_list_separator (Optional[str]): The separator to use for the edge type list. Note that, if None is provided, one will be attempted to be detected automatically between ';', ',', tab or space.
- edge_type_list_header (Optional[bool]): Whether the edge type file has an header.
- edge_type_list_rows_to_skip (Optional[int]): Number of rows to skip in the edge type list file.
- edge_type_list_is_correct (Optional[bool]): Whether the edge types file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash.
- edge_type_list_max_rows_number (Optional[int]): The maximum number of lines to be loaded from the edge types file.
- edge_type_list_comment_symbol (Optional[str]): The comment symbol to skip lines in the edge types file. Lines starting with this symbol will be skipped.
- load_edge_type_list_in_parallel (Optional[bool]): Whether to load the edge type list in parallel. When loading in parallel, without edge type IDs, the edge types may not be loaded in a deterministic order.
- edge_path (Optional[str]): The path to the file with the edge list.
- edge_list_separator (Optional[str]): The separator to use for the edge list. Note that, if None is provided, one will be attempted to be detected automatically between ';', ',', tab or space.
- edge_list_header (Optional[bool]): Whether the edges file has an header.
- edge_list_rows_to_skip (Optional[int]): Number of rows to skip in the edge list file.
- sources_column_number (Optional[int]): The number of the column of the edges file from where to load the source nodes.
- sources_column (Optional[str]): The name of the column of the edges file from where to load the source nodes.
- destinations_column_number (Optional[int]): The number of the column of the edges file from where to load the destinaton nodes.
- destinations_column (Optional[str]): The name of the column of the edges file from where to load the destinaton nodes.
- edge_list_edge_types_column_number (Optional[int]): The number of the column of the edges file from where to load the edge types.
- edge_list_edge_types_column (Optional[str]): The name of the column of the edges file from where to load the edge types.
- default_edge_type (Optional[str]): The edge type to be used when the edge type for a given edge in the edge file is None.
- weights_column_number (Optional[int]): The number of the column of the edges file from where to load the edge weights.
- weights_column (Optional[str]): The name of the column of the edges file from where to load the edge weights.
- default_weight (Optional[float]): The edge weight to be used when the edge weight for a given edge in the edge file is None.
- edge_ids_column (Optional[str]): The name of the column of the edges file from where to load the edge IDs.
- edge_ids_column_number (Optional[int]): The number of the column of the edges file from where to load the edge IDs.
- edge_list_numeric_edge_type_ids (Optional[bool]): Whether to load the edge type IDs as numeric from the edge list.
- edge_list_numeric_node_ids (Optional[bool]): Whether to load the edge node IDs as numeric from the edge list.
- skip_weights_if_unavailable (Optional[bool]): Whether to skip the weights without raising an error if these are unavailable.
- skip_edge_types_if_unavailable (Optional[bool]): Whether to skip the edge types without raising an error if these are unavailable.
- edge_list_is_complete (Optional[bool]): Whether to consider the edge list as complete, i.e. the edges are presented in both directions when loading an undirected graph.
- edge_list_may_contain_duplicates (Optional[bool]): Whether the edge list may contain duplicates. If the edge list surely DOES NOT contain duplicates, a validation step may be skipped. By default, it is assumed that the edge list may contain duplicates.
- edge_list_is_sorted (Optional[bool]): Whether the edge list is sorted. Note that a sorted edge list has the minimal memory peak, but requires the nodes number and the edges number.
- edge_list_is_correct (Optional[bool]): Whether the edges file can be assumed to be correct, i.e. does not have something wrong in it. If this parameter is passed as true on a malformed file, the constructor will crash.
- edge_list_max_rows_number (Optional[int]): The maximum number of lines to be loaded from the edges file.
- edge_list_comment_symbol (Optional[str]): The comment symbol to skip lines in the edges file. Lines starting with this symbol will be skipped.
- edges_number (Optional[int]): The expected number of edges. Note that this must be the EXACT number of edges in the graph.
- load_edge_list_in_parallel (Optional[bool]): Whether to load the edge list in parallel. Note that, if the edge IDs indices are not given, it is NOT possible to load a sorted edge list. Similarly, when loading in parallel, without edge IDs, the edges may not be loaded in a deterministic order.
- verbose (Optional[bool]): Whether to show a loading bar while reading the files. Note that, if parallel loading is enabled, loading bars will not be showed because they are a synchronization bottleneck.
- may_have_singletons (Optional[bool]): Whether the graph may be expected to have singleton nodes. If it is said that it surely DOES NOT have any, it will allow for some speedups and lower mempry peaks.
- may_have_singleton_with_selfloops (Optional[bool]): Whether the graph may be expected to have singleton nodes with selfloops. If it is said that it surely DOES NOT have any, it will allow for some speedups and lower mempry peaks.
- directed (bool): Whether to load the graph as directed or undirected.
- name (Optional[str]): The name of the graph to be loaded.
View Source
def get_connected_components_number(self, verbose: Optional[bool]) -> Tuple[int, int, int]: """Returns number a triple with (number of components, number of nodes of the smallest component, number of nodes of the biggest component ) Parameters ---------- verbose: Optional[bool] Whether to show a loading bar or not.""" pass
Returns number a triple with (number of components, number of nodes of the smallest component, number of nodes of the biggest component )
Parameters
- verbose (Optional[bool]): Whether to show a loading bar or not.
View Source
def get_number_of_connected_nodes(self) -> int: """Returns number of connected nodes in the graph.""" pass
Returns number of connected nodes in the graph.
View Source
def get_singleton_nodes_with_selfloops_number(self) -> int: """Returns number of singleton nodes with selfloops within the graph.""" pass
Returns number of singleton nodes with selfloops within the graph.
View Source
def get_number_of_singleton_nodes(self) -> int: """Returns number of singleton nodes within the graph.""" pass
Returns number of singleton nodes within the graph.
View Source
def get_number_of_disconnected_nodes(self) -> int: """Returns number of disconnected nodes within the graph. A Disconnected node is a node which is nor a singleton nor a singleton with selfloops.""" pass
Returns number of disconnected nodes within the graph. A Disconnected node is a node which is nor a singleton nor a singleton with selfloops.
View Source
def get_singleton_node_ids(self) -> np.ndarray: """Returns vector of singleton node IDs of the graph.""" pass
Returns vector of singleton node IDs of the graph.
View Source
def get_singleton_node_names(self) -> List[str]: """Returns vector of singleton node names of the graph.""" pass
Returns vector of singleton node names of the graph.
View Source
def get_singleton_with_selfloops_node_ids(self) -> np.ndarray: """Returns vector of singleton_with_selfloops node IDs of the graph.""" pass
Returns vector of singleton_with_selfloops node IDs of the graph.
View Source
def get_singleton_with_selfloops_node_names(self) -> List[str]: """Returns vector of singleton_with_selfloops node names of the graph.""" pass
Returns vector of singleton_with_selfloops node names of the graph.
View Source
def get_density(self) -> float: """Returns density of the graph.""" pass
Returns density of the graph.
View Source
def get_trap_nodes_rate(self) -> float: """Returns the traps rate of the graph. THIS IS EXPERIMENTAL AND MUST BE PROVEN!""" pass
Returns the traps rate of the graph.
THIS IS EXPERIMENTAL AND MUST BE PROVEN!
View Source
def get_node_degrees_mean(self) -> float: """Returns unweighted mean node degree of the graph.""" pass
Returns unweighted mean node degree of the graph.
View Source
def get_weighted_node_degrees_mean(self) -> float: """Returns weighted mean node degree of the graph.""" pass
Returns weighted mean node degree of the graph.
View Source
def get_undirected_edges_number(self) -> int: """Returns number of undirected edges of the graph.""" pass
Returns number of undirected edges of the graph.
View Source
def get_unique_undirected_edges_number(self) -> int: """Returns number of undirected edges of the graph.""" pass
Returns number of undirected edges of the graph.
View Source
def get_edges_number(self) -> int: """Returns number of edges of the graph.""" pass
Returns number of edges of the graph.
View Source
def get_unique_edges_number(self) -> int: """Returns number of unique edges of the graph.""" pass
Returns number of unique edges of the graph.
View Source
def get_node_degrees_median(self) -> int: """Returns unweighted median node degree of the graph""" pass
Returns unweighted median node degree of the graph
View Source
def get_weighted_node_degrees_median(self) -> float: """Returns weighted median node degree of the graph""" pass
Returns weighted median node degree of the graph
View Source
def get_maximum_node_degree(self) -> int: """Returns maximum node degree of the graph. Raises ------- ValueError If the graph does not contain any node (is an empty graph).""" pass
Returns maximum node degree of the graph.
Raises
- ValueError: If the graph does not contain any node (is an empty graph).
View Source
def get_unchecked_most_central_node_id(self) -> int: """Returns maximum node degree of the graph. Safety ------ This method fails with a panic if the graph does not have any node.""" pass
Returns maximum node degree of the graph.
Safety
This method fails with a panic if the graph does not have any node.
View Source
def get_most_central_node_id(self) -> int: """Returns maximum node degree of the graph.""" pass
Returns maximum node degree of the graph.
View Source
def get_minimum_node_degree(self) -> int: """Returns minimum node degree of the graph. Raises ------- ValueError If the graph does not contain any node (is an empty graph).""" pass
Returns minimum node degree of the graph.
Raises
- ValueError: If the graph does not contain any node (is an empty graph).
View Source
def get_node_degrees_mode(self) -> int: """Returns mode node degree of the graph.""" pass
Returns mode node degree of the graph.
View Source
def get_selfloop_nodes_rate(self) -> float: """Returns rate of self-loops.""" pass
Returns rate of self-loops.
View Source
def get_name(self) -> str: """Return name of the graph.""" pass
Return name of the graph.
View Source
def get_number_of_trap_nodes(self) -> int: """Return the number of traps (nodes without any outgoing edges that are not singletons) This also includes nodes with only a self-loops, therefore singletons with only a self-loops are not considered traps because you could make a walk on them.""" pass
Return the number of traps (nodes without any outgoing edges that are not singletons) This also includes nodes with only a self-loops, therefore singletons with only a self-loops are not considered traps because you could make a walk on them.
View Source
def get_source_node_ids(self, directed: bool) -> np.ndarray: """Return vector of the non-unique source nodes. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass
Return vector of the non-unique source nodes.
Parameters
- directed (bool): Whether to filter out the undirected edges.
View Source
def get_directed_source_node_ids(self) -> np.ndarray: """Return vector on the (non unique) directed source nodes of the graph""" pass
Return vector on the (non unique) directed source nodes of the graph
View Source
def get_source_names(self, directed: bool) -> List[str]: """Return vector of the non-unique source nodes names. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass
Return vector of the non-unique source nodes names.
Parameters
- directed (bool): Whether to filter out the undirected edges.
View Source
def get_destination_node_ids(self, directed: bool) -> np.ndarray: """Return vector on the (non unique) destination nodes of the graph. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass
Return vector on the (non unique) destination nodes of the graph.
Parameters
- directed (bool): Whether to filter out the undirected edges.
View Source
def get_directed_destination_node_ids(self) -> np.ndarray: """Return vector on the (non unique) directed destination nodes of the graph""" pass
Return vector on the (non unique) directed destination nodes of the graph
View Source
def get_destination_names(self, directed: bool) -> List[str]: """Return vector of the non-unique destination nodes names. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass
Return vector of the non-unique destination nodes names.
Parameters
- directed (bool): Whether to filter out the undirected edges.
View Source
def get_node_names(self) -> List[str]: """Return vector with the sorted nodes names""" pass
Return vector with the sorted nodes names
View Source
def get_node_urls(self) -> List[Optional[str]]: """Return vector with the node URLs.""" pass
Return vector with the node URLs.
View Source
def get_node_ontologies(self) -> List[Optional[str]]: """Return vector with the node predicted ontology.""" pass
Return vector with the node predicted ontology.
View Source
def get_node_ids(self) -> np.ndarray: """Return vector with the sorted nodes Ids""" pass
Return vector with the sorted nodes Ids
View Source
def get_edge_type_ids(self) -> List[Optional[int]]: """Return the edge types of the edges""" pass
Return the edge types of the edges
View Source
def get_unique_edge_type_ids(self) -> np.ndarray: """Return the unique edge type IDs of the graph edges.""" pass
Return the unique edge type IDs of the graph edges.
View Source
def get_edge_type_names(self) -> List[Optional[str]]: """Return the edge types names""" pass
Return the edge types names
View Source
def get_unique_edge_type_names(self) -> List[str]: """Return the edge types names""" pass
Return the edge types names
View Source
def get_edge_weights(self) -> np.ndarray: """Return the weights of the graph edges.""" pass
Return the weights of the graph edges.
View Source
def get_weighted_node_indegrees(self) -> np.ndarray: """Return the weighted indegree (total weighted inbound edge weights) for each node.""" pass
Return the weighted indegree (total weighted inbound edge weights) for each node.
View Source
def get_node_type_ids(self) -> List[Optional[List[int]]]: """Return the node types of the graph nodes.""" pass
Return the node types of the graph nodes.
View Source
def get_known_node_types_mask(self) -> np.ndarray: """Returns boolean mask of known node types. Raises ------- ValueError If the graph does not have node types.""" pass
Returns boolean mask of known node types.
Raises
- ValueError: If the graph does not have node types.
View Source
def get_unknown_node_types_mask(self) -> np.ndarray: """Returns boolean mask of unknown node types. Raises ------- ValueError If the graph does not have node types.""" pass
Returns boolean mask of unknown node types.
Raises
- ValueError: If the graph does not have node types.
View Source
def get_one_hot_encoded_node_types(self) -> np.ndarray: """Returns one-hot encoded node types. Raises ------- ValueError If the graph does not have node types.""" pass
Returns one-hot encoded node types.
Raises
- ValueError: If the graph does not have node types.
View Source
def get_one_hot_encoded_known_node_types(self) -> np.ndarray: """Returns one-hot encoded known node types. Raises ------- ValueError If the graph does not have node types.""" pass
Returns one-hot encoded known node types.
Raises
- ValueError: If the graph does not have node types.
View Source
def get_one_hot_encoded_edge_types(self) -> np.ndarray: """Returns one-hot encoded edge types. Raises ------- ValueError If the graph does not have edge types.""" pass
Returns one-hot encoded edge types.
Raises
- ValueError: If the graph does not have edge types.
View Source
def get_one_hot_encoded_known_edge_types(self) -> np.ndarray: """Returns one-hot encoded known edge types. Raises ------- ValueError If the graph does not have edge types.""" pass
Returns one-hot encoded known edge types.
Raises
- ValueError: If the graph does not have edge types.
View Source
def get_node_type_names(self) -> List[Optional[List[str]]]: """Return the node types names.""" pass
Return the node types names.
View Source
def get_unique_node_type_ids(self) -> np.ndarray: """Return the unique node type IDs of the graph nodes.""" pass
Return the unique node type IDs of the graph nodes.
View Source
def get_unique_node_type_names(self) -> List[str]: """Return the unique node types names.""" pass
Return the unique node types names.
View Source
def get_unique_directed_edges_number(self) -> int: """Return number of the unique edges in the graph""" pass
Return number of the unique edges in the graph
View Source
def get_nodes_mapping(self) -> Dict[str, int]: """Return the nodes mapping""" pass
Return the nodes mapping
View Source
def get_edge_node_ids(self, directed: bool) -> np.ndarray: """Return vector with the sorted edge Ids. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass
Return vector with the sorted edge Ids.
Parameters
- directed (bool): Whether to filter out the undirected edges.
View Source
def get_directed_edge_node_ids(self) -> np.ndarray: """Return vector with the sorted directed edge Ids""" pass
Return vector with the sorted directed edge Ids
View Source
def get_edge_node_names(self, directed: bool) -> List[Tuple[str, str]]: """Return vector with the sorted edge names. Parameters ---------- directed: bool Whether to filter out the undirected edges.""" pass
Return vector with the sorted edge names.
Parameters
- directed (bool): Whether to filter out the undirected edges.
View Source
def get_directed_edge_node_names(self) -> List[Tuple[str, str]]: """Return vector with the sorted directed edge names""" pass
Return vector with the sorted directed edge names
View Source
def get_unknown_node_types_number(self) -> int: """Returns number of nodes with unknown node type. Raises ------- ValueError If there are no node types in the graph.""" pass
Returns number of nodes with unknown node type.
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_known_node_types_number(self) -> int: """Returns the number of node with known node type. Raises ------- ValueError If there are no node types in the graph.""" pass
Returns the number of node with known node type.
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_unknown_node_types_rate(self) -> float: """Returns rate of unknown node types over total nodes number. Raises ------- ValueError If there are no node types in the graph.""" pass
Returns rate of unknown node types over total nodes number.
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_known_node_types_rate(self) -> float: """Returns rate of known node types over total nodes number. Raises ------- ValueError If there are no node types in the graph.""" pass
Returns rate of known node types over total nodes number.
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_minimum_node_types_number(self) -> int: """Returns minimum number of node types. Raises ------- ValueError If there are no node types in the graph.""" pass
Returns minimum number of node types.
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_maximum_node_types_number(self) -> int: """Returns maximum number of node types. Raises ------- ValueError If there are no node types in the graph.""" pass
Returns maximum number of node types.
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_maximum_multilabel_count(self) -> int: """Returns number of maximum multilabel count. This value is the maximum number of multilabel counts that appear in any given node in the graph""" pass
Returns number of maximum multilabel count.
This value is the maximum number of multilabel counts that appear in any given node in the graph
View Source
def get_singleton_node_types_number(self) -> int: """Returns number of singleton node types. Raises ------- ValueError If the graph does not have node types.""" pass
Returns number of singleton node types.
Raises
- ValueError: If the graph does not have node types.
View Source
def get_singleton_node_type_ids(self) -> np.ndarray: """Returns vector of singleton node types IDs. Raises ------- ValueError If the graph does not have node types.""" pass
Returns vector of singleton node types IDs.
Raises
- ValueError: If the graph does not have node types.
View Source
def get_singleton_node_type_names(self) -> List[str]: """Returns vector of singleton node types names. Raises ------- ValueError If the graph does not have node types.""" pass
Returns vector of singleton node types names.
Raises
- ValueError: If the graph does not have node types.
View Source
def get_unknown_edge_types_number(self) -> int: """Returns number of unknown edge types. Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns number of unknown edge types.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_edge_ids_with_unknown_edge_types(self) -> np.ndarray: """Returns edge IDs of the edges with unknown edge types Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns edge IDs of the edges with unknown edge types
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_edge_ids_with_known_edge_types(self) -> np.ndarray: """Returns edge IDs of the edges with known edge types Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns edge IDs of the edges with known edge types
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_edge_node_ids_with_unknown_edge_types(self, directed: bool) -> List[Tuple[int, int]]: """Returns edge node IDs of the edges with unknown edge types Parameters ---------- directed: bool Whether to iterated the edges as a directed or undirected edge list. Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns edge node IDs of the edges with unknown edge types
Parameters
- directed (bool): Whether to iterated the edges as a directed or undirected edge list.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_edge_node_ids_with_known_edge_types(self, directed: bool) -> List[Tuple[int, int]]: """Returns edge node IDs of the edges with known edge types Parameters ---------- directed: bool Whether to iterated the edges as a directed or undirected edge list. Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns edge node IDs of the edges with known edge types
Parameters
- directed (bool): Whether to iterated the edges as a directed or undirected edge list.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_edge_node_names_with_unknown_edge_types(self, directed: bool) -> List[Tuple[str, str]]: """Returns edge node names of the edges with unknown edge types Parameters ---------- directed: bool Whether to iterated the edges as a directed or undirected edge list. Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns edge node names of the edges with unknown edge types
Parameters
- directed (bool): Whether to iterated the edges as a directed or undirected edge list.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_edge_node_names_with_known_edge_types(self, directed: bool) -> List[Tuple[str, str]]: """Returns edge node names of the edges with known edge types Parameters ---------- directed: bool Whether to iterated the edges as a directed or undirected edge list. Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns edge node names of the edges with known edge types
Parameters
- directed (bool): Whether to iterated the edges as a directed or undirected edge list.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_edge_ids_with_unknown_edge_types_mask(self) -> np.ndarray: """Returns a boolean vector that for each node contains whether it has an unknown node type. Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns a boolean vector that for each node contains whether it has an unknown node type.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_edge_ids_with_known_edge_types_mask(self) -> np.ndarray: """Returns a boolean vector that for each node contains whether it has an unknown edge type. Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns a boolean vector that for each node contains whether it has an unknown edge type.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_node_ids_with_unknown_node_types(self) -> np.ndarray: """Returns node IDs of the nodes with unknown node types Raises ------- ValueError If there are no node types in the graph.""" pass
Returns node IDs of the nodes with unknown node types
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_node_ids_with_known_node_types(self) -> np.ndarray: """Returns node IDs of the nodes with known node types Raises ------- ValueError If there are no node types in the graph.""" pass
Returns node IDs of the nodes with known node types
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_node_names_with_unknown_node_types(self) -> List[str]: """Returns node names of the nodes with unknown node types Raises ------- ValueError If there are no node types in the graph.""" pass
Returns node names of the nodes with unknown node types
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_node_names_with_known_node_types(self) -> List[str]: """Returns node names of the nodes with known node types Raises ------- ValueError If there are no node types in the graph.""" pass
Returns node names of the nodes with known node types
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_node_ids_with_unknown_node_types_mask(self) -> np.ndarray: """Returns a boolean vector that for each node contains whether it has an unknown node type. Raises ------- ValueError If there are no node types in the graph.""" pass
Returns a boolean vector that for each node contains whether it has an unknown node type.
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_node_ids_with_known_node_types_mask(self) -> np.ndarray: """Returns a boolean vector that for each node contains whether it has an known node type. Raises ------- ValueError If there are no node types in the graph.""" pass
Returns a boolean vector that for each node contains whether it has an known node type.
Raises
- ValueError: If there are no node types in the graph.
View Source
def get_known_edge_types_number(self) -> int: """Returns the number of edge with known edge type. Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns the number of edge with known edge type.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_unknown_edge_types_rate(self) -> float: """Returns rate of unknown edge types over total edges number. Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns rate of unknown edge types over total edges number.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_known_edge_types_rate(self) -> float: """Returns rate of known edge types over total edges number. Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns rate of known edge types over total edges number.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_minimum_edge_types_number(self) -> int: """Returns minimum number of edge types. Raises ------- ValueError If there are no edge types in the graph.""" pass
Returns minimum number of edge types.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def get_singleton_edge_types_number(self) -> int: """Returns number of singleton edge types. Raises ------- ValueError If the graph does not have edge types.""" pass
Returns number of singleton edge types.
Raises
- ValueError: If the graph does not have edge types.
View Source
def get_singleton_edge_type_ids(self) -> np.ndarray: """Returns vector of singleton edge types IDs. Raises ------- ValueError If the graph does not have edge types.""" pass
Returns vector of singleton edge types IDs.
Raises
- ValueError: If the graph does not have edge types.
View Source
def get_singleton_edge_type_names(self) -> List[str]: """Returns vector of singleton edge types names. Raises ------- ValueError If the graph does not have edge types.""" pass
Returns vector of singleton edge types names.
Raises
- ValueError: If the graph does not have edge types.
View Source
def get_number_of_nodes(self) -> int: """Returns number of nodes in the graph""" pass
Returns number of nodes in the graph
View Source
def get_node_connected_component_ids(self, verbose: Optional[bool]) -> np.ndarray: """Return a vector with the components each node belongs to. E.g. If we have two components `[0, 2, 3]` and `[1, 4, 5]` the result will look like `[0, 1, 0, 0, 1, 1]` Parameters ---------- verbose: Optional[bool] Whether to show the loading bar.""" pass
Return a vector with the components each node belongs to.
E.g. If we have two components [0, 2, 3]
and [1, 4, 5]
the result will look like
[0, 1, 0, 0, 1, 1]
Parameters
- verbose (Optional[bool]): Whether to show the loading bar.
View Source
def get_directed_edges_number(self) -> int: """Returns number of directed edges in the graph""" pass
Returns number of directed edges in the graph
View Source
def get_edge_types_number(self) -> int: """Returns number of edge types in the graph. Raises ------- ValueError If there are no edge types in the current graph.""" pass
Returns number of edge types in the graph.
Raises
- ValueError: If there are no edge types in the current graph.
View Source
def get_node_types_number(self) -> int: """Returns number of node types in the graph. Raises ------- ValueError If there are no node types in the current graph.""" pass
Returns number of node types in the graph.
Raises
- ValueError: If there are no node types in the current graph.
View Source
def get_node_degrees(self) -> np.ndarray: """Returns the unweighted degree of every node in the graph""" pass
Returns the unweighted degree of every node in the graph
View Source
def get_node_indegrees(self) -> np.ndarray: """Return the indegree for each node.""" pass
Return the indegree for each node.
View Source
def get_weighted_node_degrees(self) -> np.ndarray: """Returns the weighted degree of every node in the graph""" pass
Returns the weighted degree of every node in the graph
View Source
def get_not_singletons_node_ids(self) -> np.ndarray: """Return set of nodes that are not singletons""" pass
Return set of nodes that are not singletons
View Source
def get_dense_nodes_mapping(self) -> Dict[int, int]: """Return mapping from instance not trap nodes to dense nodes""" pass
Return mapping from instance not trap nodes to dense nodes
View Source
def get_parallel_edges_number(self) -> int: """Return number of edges that have multigraph syblings""" pass
Return number of edges that have multigraph syblings
View Source
def get_cumulative_node_degrees(self) -> np.ndarray: """Return vector with node cumulative_node_degrees, that is the comulative node degree""" pass
Return vector with node cumulative_node_degrees, that is the comulative node degree
View Source
def get_reciprocal_sqrt_degrees(self) -> np.ndarray: """Return vector wit""" pass
Return vector wit
View Source
def get_number_of_unique_source_nodes(self) -> int: """Returns number of the source nodes.""" pass
Returns number of the source nodes.
View Source
def get_edge_type_id_counts_hashmap(self) -> Dict[int, int]: """Returns edge type IDs counts hashmap. Raises ------- ValueError If there are no edge types in the current graph instance.""" pass
Returns edge type IDs counts hashmap.
Raises
- ValueError: If there are no edge types in the current graph instance.
View Source
def get_edge_type_names_counts_hashmap(self) -> Dict[str, int]: """Returns edge type names counts hashmap. Raises ------- ValueError If there are no edge types in the current graph instance.""" pass
Returns edge type names counts hashmap.
Raises
- ValueError: If there are no edge types in the current graph instance.
View Source
def get_node_type_id_counts_hashmap(self) -> Dict[int, int]: """Returns node type IDs counts hashmap. Raises ------- ValueError If there are no node types in the current graph instance.""" pass
Returns node type IDs counts hashmap.
Raises
- ValueError: If there are no node types in the current graph instance.
View Source
def get_node_type_names_counts_hashmap(self) -> Dict[str, int]: """Returns node type names counts hashmap. Raises ------- ValueError If there are no node types in the current graph instance.""" pass
Returns node type names counts hashmap.
Raises
- ValueError: If there are no node types in the current graph instance.
View Source
def has_default_graph_name(self) -> bool: """Return if graph has name that is not the default one. TODO: use a default for the default graph name""" pass
Return if graph has name that is not the default one.
TODO: use a default for the default graph name
View Source
def has_nodes(self) -> bool: """Return if the graph has any nodes.""" pass
Return if the graph has any nodes.
View Source
def has_edges(self) -> bool: """Return if the graph has any edges.""" pass
Return if the graph has any edges.
View Source
def has_trap_nodes(self) -> bool: """Return whether the graph has trap nodes.""" pass
Return whether the graph has trap nodes.
View Source
def is_directed(self) -> bool: """Returns boolean representing if graph is directed.""" pass
Returns boolean representing if graph is directed.
View Source
def has_edge_weights(self) -> bool: """Returns boolean representing whether graph has weights.""" pass
Returns boolean representing whether graph has weights.
View Source
def has_edge_weights_representing_probabilities(self) -> bool: """Returns whether graph has weights that can represent probabilities""" pass
Returns whether graph has weights that can represent probabilities
View Source
def has_weighted_singleton_nodes(self) -> bool: """Returns whether a graph has one or more weighted singleton nodes. A weighted singleton node is a node whose weighted node degree is 0. Raises ------- ValueError If the graph does not contain edge weights.""" pass
Returns whether a graph has one or more weighted singleton nodes.
A weighted singleton node is a node whose weighted node degree is 0.
Raises
- ValueError: If the graph does not contain edge weights.
View Source
def has_constant_edge_weights(self) -> bool: """Returns whether the graph has constant weights. Raises ------- ValueError If the graph does not contain edge weights.""" pass
Returns whether the graph has constant weights.
Raises
- ValueError: If the graph does not contain edge weights.
View Source
def has_negative_edge_weights(self) -> bool: """Returns boolean representing whether graph has negative weights. Raises ------- ValueError If the graph does not contain weights.""" pass
Returns boolean representing whether graph has negative weights.
Raises
- ValueError: If the graph does not contain weights.
View Source
def has_edge_types(self) -> bool: """Returns boolean representing whether graph has edge types.""" pass
Returns boolean representing whether graph has edge types.
View Source
def has_selfloops(self) -> bool: """Returns boolean representing if graph has self-loops.""" pass
Returns boolean representing if graph has self-loops.
View Source
def has_disconnected_nodes(self) -> bool: """Returns boolean representing if nodes which are nor singletons nor singletons with selfloops.""" pass
Returns boolean representing if nodes which are nor singletons nor singletons with selfloops.
View Source
def has_singleton_nodes(self) -> bool: """Returns boolean representing if graph has singletons.""" pass
Returns boolean representing if graph has singletons.
View Source
def has_singleton_nodes_with_selfloops(self) -> bool: """Returns boolean representing if graph has singletons""" pass
Returns boolean representing if graph has singletons
View Source
def is_connected(self, verbose: Optional[bool]) -> bool: """Returns whether the graph is connected. Parameters ---------- verbose: Optional[bool] Whether to show the loading bar while computing the connected components, if necessary.""" pass
Returns whether the graph is connected.
Parameters
- verbose (Optional[bool]): Whether to show the loading bar while computing the connected components, if necessary.
View Source
def has_node_types(self) -> bool: """Returns boolean representing if graph has node types""" pass
Returns boolean representing if graph has node types
View Source
def has_multilabel_node_types(self) -> bool: """Returns boolean representing if graph has multilabel node types. Raises ------- ValueError If the graph does not have node types.""" pass
Returns boolean representing if graph has multilabel node types.
Raises
- ValueError: If the graph does not have node types.
View Source
def has_unknown_node_types(self) -> bool: """Returns whether there are unknown node types. Raises ------- ValueError If the graph does not have node types.""" pass
Returns whether there are unknown node types.
Raises
- ValueError: If the graph does not have node types.
View Source
def has_known_node_types(self) -> bool: """Returns whether there are known node types. Raises ------- ValueError If the graph does not have node types.""" pass
Returns whether there are known node types.
Raises
- ValueError: If the graph does not have node types.
View Source
def has_unknown_edge_types(self) -> bool: """Returns whether there are unknown edge types. Raises ------- ValueError If the graph does not have node types.""" pass
Returns whether there are unknown edge types.
Raises
- ValueError: If the graph does not have node types.
View Source
def has_known_edge_types(self) -> bool: """Returns whether there are known edge types. Raises ------- ValueError If the graph does not have edge types.""" pass
Returns whether there are known edge types.
Raises
- ValueError: If the graph does not have edge types.
View Source
def has_homogeneous_node_types(self) -> bool: """Returns whether the nodes have an homogenous node type. Raises ------- ValueError If the graph does not have node types.""" pass
Returns whether the nodes have an homogenous node type.
Raises
- ValueError: If the graph does not have node types.
View Source
def has_homogeneous_edge_types(self) -> bool: """Returns whether the edges have an homogenous edge type. Raises ------- ValueError If the graph does not have edge types.""" pass
Returns whether the edges have an homogenous edge type.
Raises
- ValueError: If the graph does not have edge types.
View Source
def has_singleton_node_types(self) -> bool: """Returns whether there is at least singleton node type, that is a node type that only appears once. Raises ------- ValueError If the graph does not have node types.""" pass
Returns whether there is at least singleton node type, that is a node type that only appears once.
Raises
- ValueError: If the graph does not have node types.
View Source
def has_node_oddities(self) -> bool: """Return whether the graph has any known node-related graph oddities""" pass
Return whether the graph has any known node-related graph oddities
View Source
def has_node_types_oddities(self) -> bool: """Return whether the graph has any known node type-related graph oddities. Raises ------- ValueError If the graph does not have node types.""" pass
Return whether the graph has any known node type-related graph oddities.
Raises
- ValueError: If the graph does not have node types.
View Source
def has_singleton_edge_types(self) -> bool: """Returns whether there is at least singleton edge type, that is a edge type that only appears once. Raises ------- ValueError If the graph does not have edge types.""" pass
Returns whether there is at least singleton edge type, that is a edge type that only appears once.
Raises
- ValueError: If the graph does not have edge types.
View Source
def has_edge_types_oddities(self) -> bool: """Return whether the graph has any known edge type-related graph oddities. Raises ------- ValueError If the graph does not have edge types.""" pass
Return whether the graph has any known edge type-related graph oddities.
Raises
- ValueError: If the graph does not have edge types.
View Source
def is_multigraph(self) -> bool: """Return if there are multiple edges between two node""" pass
Return if there are multiple edges between two node
View Source
def has_nodes_sorted_by_decreasing_outbound_node_degree(self) -> bool: """Returns whether the node IDs are sorted by decreasing outbound node degree.""" pass
Returns whether the node IDs are sorted by decreasing outbound node degree.
View Source
def has_nodes_sorted_by_lexicographic_order(self) -> bool: """Returns whether the node IDs are sorted by decreasing outbound node degree.""" pass
Returns whether the node IDs are sorted by decreasing outbound node degree.
View Source
def contains_identity_matrix(self) -> bool: """Returns whether the graph contains the indentity matrix.""" pass
Returns whether the graph contains the indentity matrix.
View Source
def has_nodes_sorted_by_increasing_outbound_node_degree(self) -> bool: """Returns whether the node IDs are sorted by increasing outbound node degree.""" pass
Returns whether the node IDs are sorted by increasing outbound node degree.
View Source
def get_total_edge_weights(self) -> float: """Return total edge weights, if graph has weights. Raises ------- ValueError If the graph does not contain edge weights.""" pass
Return total edge weights, if graph has weights.
Raises
- ValueError: If the graph does not contain edge weights.
View Source
def get_mininum_edge_weight(self) -> float: """Return the minimum weight, if graph has weights. Raises ------- ValueError If the graph does not contain edge weights.""" pass
Return the minimum weight, if graph has weights.
Raises
- ValueError: If the graph does not contain edge weights.
View Source
def get_maximum_edge_weight(self) -> float: """Return the maximum weight, if graph has weights. Raises ------- ValueError If the graph does not contain edge weights.""" pass
Return the maximum weight, if graph has weights.
Raises
- ValueError: If the graph does not contain edge weights.
View Source
def get_unchecked_maximum_node_degree(self) -> int: """Return the maximum node degree. Safety ------ The method will return an undefined value (0) when the graph does not contain nodes. In those cases the value is not properly defined.""" pass
Return the maximum node degree.
Safety
The method will return an undefined value (0) when the graph does not contain nodes. In those cases the value is not properly defined.
View Source
def get_unchecked_minimum_node_degree(self) -> int: """Return the minimum node degree. Safety ------ The method will return an undefined value (0) when the graph does not contain nodes. In those cases the value is not properly defined.""" pass
Return the minimum node degree.
Safety
The method will return an undefined value (0) when the graph does not contain nodes. In those cases the value is not properly defined.
View Source
def get_weighted_maximum_node_degree(self) -> float: """Return the maximum weighted node degree""" pass
Return the maximum weighted node degree
View Source
def get_weighted_minimum_node_degree(self) -> float: """Return the minimum weighted node degree""" pass
Return the minimum weighted node degree
View Source
def get_number_of_weighted_singleton_nodes(self) -> int: """Return the number of weighted singleton nodes, i.e. nodes with weighted node degree equal to zero""" pass
Return the number of weighted singleton nodes, i.e. nodes with weighted node degree equal to zero
View Source
def get_selfloops_number(self) -> int: """Returns number of self-loops, including also those in eventual multi-edges.""" pass
Returns number of self-loops, including also those in eventual multi-edges.
View Source
def get_unique_selfloops_number(self) -> int: """Returns number of unique self-loops, excluding those in eventual multi-edges.""" pass
Returns number of unique self-loops, excluding those in eventual multi-edges.
View Source
def overlaps(self, other: Graph) -> bool: """Return whether given graph has any edge overlapping with current graph. Parameters ---------- other: Graph The graph to check against. Raises ------- ValueError If a graph is directed and the other is undirected. ValueError If one of the two graphs has edge weights and the other does not. ValueError If one of the two graphs has node types and the other does not. ValueError If one of the two graphs has edge types and the other does not.""" pass
Return whether given graph has any edge overlapping with current graph.
Parameters
- other (Graph): The graph to check against.
Raises
- ValueError: If a graph is directed and the other is undirected.
- ValueError: If one of the two graphs has edge weights and the other does not.
- ValueError: If one of the two graphs has node types and the other does not.
- ValueError: If one of the two graphs has edge types and the other does not.
View Source
def contains(self, other: Graph) -> bool: """Return true if given graph edges are all contained within current graph. Parameters ---------- other: Graph The graph to check against. Raises ------- ValueError If a graph is directed and the other is undirected. ValueError If one of the two graphs has edge weights and the other does not. ValueError If one of the two graphs has node types and the other does not. ValueError If one of the two graphs has edge types and the other does not.""" pass
Return true if given graph edges are all contained within current graph.
Parameters
- other (Graph): The graph to check against.
Raises
- ValueError: If a graph is directed and the other is undirected.
- ValueError: If one of the two graphs has edge weights and the other does not.
- ValueError: If one of the two graphs has node types and the other does not.
- ValueError: If one of the two graphs has edge types and the other does not.
View Source
def sample_negatives(self, negatives_number: int, random_state: Optional[int], seed_graph: Optional[Graph], only_from_same_component: Optional[bool], verbose: Optional[bool]) -> Graph: """Returns Graph with given amount of negative edges as positive edges. The graph generated may be used as a testing negatives partition to be fed into the argument "graph_to_avoid" of the link_prediction or the skipgrams algorithm Parameters ---------- negatives_number: int Number of negatives edges to include. random_state: Optional[int] random_state to use to reproduce negative edge set. seed_graph: Optional[Graph] Optional graph to use to filter the negative edges. The negative edges generated when this variable is provided will always have a node within this graph. only_from_same_component: Optional[bool] Whether to sample negative edges only from nodes that are from the same component. verbose: Optional[bool] Whether to show the loading bar.""" pass
Returns Graph with given amount of negative edges as positive edges.
The graph generated may be used as a testing negatives partition to be fed into the argument "graph_to_avoid" of the link_prediction or the skipgrams algorithm
Parameters
- negatives_number (int): Number of negatives edges to include.
- random_state (Optional[int]): random_state to use to reproduce negative edge set.
- seed_graph (Optional[Graph]): Optional graph to use to filter the negative edges. The negative edges generated when this variable is provided will always have a node within this graph.
- only_from_same_component (Optional[bool]): Whether to sample negative edges only from nodes that are from the same component.
- verbose (Optional[bool]): Whether to show the loading bar.
View Source
def connected_holdout(self, train_size: float, random_state: Optional[int], edge_types: Optional[List[Optional[str]]], include_all_edge_types: Optional[bool], verbose: Optional[bool]) -> Tuple[Graph, Graph]: """Returns holdout for training ML algorithms on the graph structure. The holdouts returned are a tuple of graphs. The first one, which is the training graph, is garanteed to have the same number of graph components as the initial graph. The second graph is the graph meant for testing or validation of the algorithm, and has no garantee to be connected. It will have at most (1-train_size) edges, as the bound of connectivity which is required for the training graph may lead to more edges being left into the training partition. In the option where a list of edge types has been provided, these edge types will be those put into the validation set. Parameters ---------- train_size: float Rate target to reserve for training. random_state: Optional[int] The random_state to use for the holdout, edge_types: Optional[List[Optional[str]]] Edge types to be selected for in the validation set. include_all_edge_types: Optional[bool] Whether to include all the edges between two nodes. verbose: Optional[bool] Whether to show the loading bar. Raises ------- ValueError If the edge types have been specified but the graph does not have edge types. ValueError If the required training size is not a real value between 0 and 1. ValueError If the current graph does not allow for the creation of a spanning tree for the requested training size.""" pass
Returns holdout for training ML algorithms on the graph structure.
The holdouts returned are a tuple of graphs. The first one, which is the training graph, is garanteed to have the same number of graph components as the initial graph. The second graph is the graph meant for testing or validation of the algorithm, and has no garantee to be connected. It will have at most (1-train_size) edges, as the bound of connectivity which is required for the training graph may lead to more edges being left into the training partition.
In the option where a list of edge types has been provided, these edge types will be those put into the validation set.
Parameters
- train_size (float): Rate target to reserve for training.
- random_state (Optional[int]): The random_state to use for the holdout,
- edge_types (Optional[List[Optional[str]]]): Edge types to be selected for in the validation set.
- include_all_edge_types (Optional[bool]): Whether to include all the edges between two nodes.
- verbose (Optional[bool]): Whether to show the loading bar.
Raises
- ValueError: If the edge types have been specified but the graph does not have edge types.
- ValueError: If the required training size is not a real value between 0 and 1.
- ValueError: If the current graph does not allow for the creation of a spanning tree for the requested training size.
View Source
def random_holdout(self, train_size: float, random_state: Optional[int], include_all_edge_types: Optional[bool], edge_types: Optional[List[Optional[str]]], min_number_overlaps: Optional[int], verbose: Optional[bool]) -> Tuple[Graph, Graph]: """Returns random holdout for training ML algorithms on the graph edges. The holdouts returned are a tuple of graphs. In neither holdouts the graph connectivity is necessarily preserved. To maintain that, use the method `connected_holdout`. Parameters ---------- train_size: float rate target to reserve for training random_state: Optional[int] The random_state to use for the holdout, include_all_edge_types: Optional[bool] Whether to include all the edges between two nodes. edge_types: Optional[List[Optional[str]]] The edges to include in validation set. min_number_overlaps: Optional[int] The minimum number of overlaps to include the edge into the validation set. verbose: Optional[bool] Whether to show the loading bar. Raises ------- ValueError If the edge types have been specified but the graph does not have edge types. ValueError If the minimum number of overlaps have been specified but the graph is not a multigraph. ValueError If one or more of the given edge type names is not present in the graph.""" pass
Returns random holdout for training ML algorithms on the graph edges.
The holdouts returned are a tuple of graphs. In neither holdouts the
graph connectivity is necessarily preserved. To maintain that, use
the method connected_holdout
.
Parameters
- train_size (float): rate target to reserve for training
- random_state (Optional[int]): The random_state to use for the holdout,
- include_all_edge_types (Optional[bool]): Whether to include all the edges between two nodes.
- edge_types (Optional[List[Optional[str]]]): The edges to include in validation set.
- min_number_overlaps (Optional[int]): The minimum number of overlaps to include the edge into the validation set.
- verbose (Optional[bool]): Whether to show the loading bar.
Raises
- ValueError: If the edge types have been specified but the graph does not have edge types.
- ValueError: If the minimum number of overlaps have been specified but the graph is not a multigraph.
- ValueError: If one or more of the given edge type names is not present in the graph.
View Source
def get_node_label_holdout_indices(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[List[int], List[int]]: """Returns node-label holdout indices for training ML algorithms on the graph node labels. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use node-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have node types. ValueError If stratification is requested but the graph has a single node type. ValueError If stratification is requested but the graph has a multilabel node types.""" pass
Returns node-label holdout indices for training ML algorithms on the graph node labels.
Parameters
- train_size (float): rate target to reserve for training,
- use_stratification (Optional[bool]): Whether to use node-label stratification,
- random_state (Optional[int]): The random_state to use for the holdout,
Raises
- ValueError: If the graph does not have node types.
- ValueError: If stratification is requested but the graph has a single node type.
- ValueError: If stratification is requested but the graph has a multilabel node types.
View Source
def get_node_label_holdout_labels(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[List[Optional[List[int]]], List[Optional[List[int]]]]: """Returns node-label holdout indices for training ML algorithms on the graph node labels. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use node-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have node types. ValueError If stratification is requested but the graph has a single node type. ValueError If stratification is requested but the graph has a multilabel node types.""" pass
Returns node-label holdout indices for training ML algorithms on the graph node labels.
Parameters
- train_size (float): rate target to reserve for training,
- use_stratification (Optional[bool]): Whether to use node-label stratification,
- random_state (Optional[int]): The random_state to use for the holdout,
Raises
- ValueError: If the graph does not have node types.
- ValueError: If stratification is requested but the graph has a single node type.
- ValueError: If stratification is requested but the graph has a multilabel node types.
View Source
def get_node_label_holdout_graphs(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns node-label holdout for training ML algorithms on the graph node labels. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use node-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have node types. ValueError If stratification is requested but the graph has a single node type. ValueError If stratification is requested but the graph has a multilabel node types.""" pass
Returns node-label holdout for training ML algorithms on the graph node labels.
Parameters
- train_size (float): rate target to reserve for training,
- use_stratification (Optional[bool]): Whether to use node-label stratification,
- random_state (Optional[int]): The random_state to use for the holdout,
Raises
- ValueError: If the graph does not have node types.
- ValueError: If stratification is requested but the graph has a single node type.
- ValueError: If stratification is requested but the graph has a multilabel node types.
View Source
def get_edge_label_holdout_graphs(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns edge-label holdout for training ML algorithms on the graph edge labels. This is commonly used for edge type prediction tasks. This method returns two graphs, the train and the test one. The edges of the graph will be splitted in the train and test graphs according to the `train_size` argument. If stratification is enabled, the train and test will have the same ratios of edge types. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use edge-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have edge types. ValueError If stratification is required but the graph has singleton edge types.""" pass
Returns edge-label holdout for training ML algorithms on the graph edge labels. This is commonly used for edge type prediction tasks.
This method returns two graphs, the train and the test one.
The edges of the graph will be splitted in the train and test graphs according
to the train_size
argument.
If stratification is enabled, the train and test will have the same ratios of edge types.
Parameters
- train_size (float): rate target to reserve for training,
- use_stratification (Optional[bool]): Whether to use edge-label stratification,
- random_state (Optional[int]): The random_state to use for the holdout,
Raises
- ValueError: If the graph does not have edge types.
- ValueError: If stratification is required but the graph has singleton edge types.
View Source
def get_random_subgraph(self, number_of_nodes: int, random_state: Optional[int], verbose: Optional[bool]) -> Graph: """Returns subgraph with given number of nodes. **This method creates a subset of the graph starting from a random node sampled using given random_state and includes all neighbouring nodes until the required number of nodes is reached**. All the edges connecting any of the selected nodes are then inserted into this graph. This is meant to execute distributed node embeddings. It may also sample singleton nodes. Parameters ---------- number_of_nodes: int Number of nodes to extract. random_state: Optional[int] Random random_state to use. verbose: Optional[bool] Whether to show the loading bar. Raises ------- ValueError If the requested number of nodes is one or less. ValueError If the graph has less than the requested number of nodes.""" pass
Returns subgraph with given number of nodes.
This method creates a subset of the graph starting from a random node sampled using given random_state and includes all neighbouring nodes until the required number of nodes is reached. All the edges connecting any of the selected nodes are then inserted into this graph.
This is meant to execute distributed node embeddings. It may also sample singleton nodes.
Parameters
- number_of_nodes (int): Number of nodes to extract.
- random_state (Optional[int]): Random random_state to use.
- verbose (Optional[bool]): Whether to show the loading bar.
Raises
- ValueError: If the requested number of nodes is one or less.
- ValueError: If the graph has less than the requested number of nodes.
View Source
def get_node_label_random_holdout(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns node-label holdout for training ML algorithms on the graph node labels. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use node-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have node types. ValueError If stratification is requested but the graph has a single node type. ValueError If stratification is requested but the graph has a multilabel node types.""" pass
Returns node-label holdout for training ML algorithms on the graph node labels.
Parameters
- train_size (float): rate target to reserve for training,
- use_stratification (Optional[bool]): Whether to use node-label stratification,
- random_state (Optional[int]): The random_state to use for the holdout,
Raises
- ValueError: If the graph does not have node types.
- ValueError: If stratification is requested but the graph has a single node type.
- ValueError: If stratification is requested but the graph has a multilabel node types.
View Source
def get_node_label_kfold(self, k: int, k_index: int, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns node-label fold for training ML algorithms on the graph node labels. Parameters ---------- k: int The number of folds. k_index: int Which fold to use for the validation. use_stratification: Optional[bool] Whether to use node-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have node types. ValueError If stratification is requested but the graph has a single node type. ValueError If stratification is requested but the graph has a multilabel node types.""" pass
Returns node-label fold for training ML algorithms on the graph node labels.
Parameters
- k (int): The number of folds.
- k_index (int): Which fold to use for the validation.
- use_stratification (Optional[bool]): Whether to use node-label stratification,
- random_state (Optional[int]): The random_state to use for the holdout,
Raises
- ValueError: If the graph does not have node types.
- ValueError: If stratification is requested but the graph has a single node type.
- ValueError: If stratification is requested but the graph has a multilabel node types.
View Source
def get_edge_label_random_holdout(self, train_size: float, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns edge-label holdout for training ML algorithms on the graph edge labels. This is commonly used for edge type prediction tasks. This method returns two graphs, the train and the test one. The edges of the graph will be splitted in the train and test graphs according to the `train_size` argument. If stratification is enabled, the train and test will have the same ratios of edge types. Parameters ---------- train_size: float rate target to reserve for training, use_stratification: Optional[bool] Whether to use edge-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have edge types. ValueError If stratification is required but the graph has singleton edge types.""" pass
Returns edge-label holdout for training ML algorithms on the graph edge labels. This is commonly used for edge type prediction tasks.
This method returns two graphs, the train and the test one.
The edges of the graph will be splitted in the train and test graphs according
to the train_size
argument.
If stratification is enabled, the train and test will have the same ratios of edge types.
Parameters
- train_size (float): rate target to reserve for training,
- use_stratification (Optional[bool]): Whether to use edge-label stratification,
- random_state (Optional[int]): The random_state to use for the holdout,
Raises
- ValueError: If the graph does not have edge types.
- ValueError: If stratification is required but the graph has singleton edge types.
View Source
def get_edge_label_kfold(self, k: int, k_index: int, use_stratification: Optional[bool], random_state: Optional[int]) -> Tuple[Graph, Graph]: """Returns edge-label kfold for training ML algorithms on the graph edge labels. This is commonly used for edge type prediction tasks. This method returns two graphs, the train and the test one. The edges of the graph will be splitted in the train and test graphs according to the `train_size` argument. If stratification is enabled, the train and test will have the same ratios of edge types. Parameters ---------- k: int The number of folds. k_index: int Which fold to use for the validation. use_stratification: Optional[bool] Whether to use edge-label stratification, random_state: Optional[int] The random_state to use for the holdout, Raises ------- ValueError If the graph does not have edge types. ValueError If stratification is required but the graph has singleton edge types.""" pass
Returns edge-label kfold for training ML algorithms on the graph edge labels. This is commonly used for edge type prediction tasks.
This method returns two graphs, the train and the test one.
The edges of the graph will be splitted in the train and test graphs according
to the train_size
argument.
If stratification is enabled, the train and test will have the same ratios of edge types.
Parameters
- k (int): The number of folds.
- k_index (int): Which fold to use for the validation.
- use_stratification (Optional[bool]): Whether to use edge-label stratification,
- random_state (Optional[int]): The random_state to use for the holdout,
Raises
- ValueError: If the graph does not have edge types.
- ValueError: If stratification is required but the graph has singleton edge types.
View Source
def get_edge_prediction_kfold(self, k: int, k_index: int, edge_types: Optional[List[Optional[str]]], random_state: Optional[int], verbose: Optional[bool]) -> Tuple[Graph, Graph]: """Returns train and test graph following kfold validation scheme. The edges are splitted into k chunks. The k_index-th chunk is used to build the validation graph, all the other edges create the training graph. Parameters ---------- k: int The number of folds. k_index: int Which fold to use for the validation. edge_types: Optional[List[Optional[str]]] Edge types to be selected when computing the folds (All the edge types not listed here will be always be used in the training set). random_state: Optional[int] The random_state (seed) to use for the holdout, verbose: Optional[bool] Whether to show the loading bar. Raises ------- ValueError If the number of requested k folds is one or zero. ValueError If the given k fold index is greater than the number of k folds. ValueError If edge types have been specified but it's an empty list. ValueError If the number of k folds is higher than the number of edges in the graph.""" pass
Returns train and test graph following kfold validation scheme.
The edges are splitted into k chunks. The k_index-th chunk is used to build the validation graph, all the other edges create the training graph.
Parameters
- k (int): The number of folds.
- k_index (int): Which fold to use for the validation.
- edge_types (Optional[List[Optional[str]]]): Edge types to be selected when computing the folds (All the edge types not listed here will be always be used in the training set).
- random_state (Optional[int]): The random_state (seed) to use for the holdout,
- verbose (Optional[bool]): Whether to show the loading bar.
Raises
- ValueError: If the number of requested k folds is one or zero.
- ValueError: If the given k fold index is greater than the number of k folds.
- ValueError: If edge types have been specified but it's an empty list.
- ValueError: If the number of k folds is higher than the number of edges in the graph.
View Source
def get_laplacian_transformed_graph(self) -> Graph: """Returns unweighted laplacian transformation of the graph""" pass
Returns unweighted laplacian transformation of the graph
View Source
def get_laplacian_coo_matrix_edges_number(self) -> int: """Returns number of edges in the laplacian COO matrix representation of the graph""" pass
Returns number of edges in the laplacian COO matrix representation of the graph
View Source
def get_random_walk_normalized_laplacian_transformed_graph(self) -> Graph: """Returns unweighted random walk normalized laplacian transformation of the graph""" pass
Returns unweighted random walk normalized laplacian transformation of the graph
View Source
def get_symmetric_normalized_laplacian_transformed_graph(self) -> Graph: """Returns unweighted symmetric normalized laplacian transformation of the graph. Raises ------- ValueError The graph must be undirected, as we do not currently support this transformation for directed graphs.""" pass
Returns unweighted symmetric normalized laplacian transformation of the graph.
Raises
- ValueError: The graph must be undirected, as we do not currently support this transformation for directed graphs.
View Source
def get_symmetric_normalized_transformed_graph(self) -> Graph: """Returns unweighted symmetric normalized transformation of the graph. Raises ------- ValueError The graph must be undirected, as we do not currently support this transformation for directed graphs.""" pass
Returns unweighted symmetric normalized transformation of the graph.
Raises
- ValueError: The graph must be undirected, as we do not currently support this transformation for directed graphs.
View Source
def get_undirected_louvain_community_detection(self, recursion_minimum_improvement: Optional[float], first_phase_minimum_improvement: Optional[float], patience: Optional[int], random_state: Optional[int]) -> List[List[int]]: """Returns vector of vectors of communities for each layer of hierarchy minimizing undirected modularity. Parameters ---------- recursion_minimum_improvement: Optional[float] The minimum improvement to warrant another resursion round. By default, zero. first_phase_minimum_improvement: Optional[float] The minimum improvement to warrant another first phase iteration. By default, `0.00001` (not zero because of numerical instability). patience: Optional[int] How many iterations of the first phase to wait for before stopping. By default, `5`. random_state: Optional[int] The random state to use to reproduce this modularity computation. By default, 42. Raises ------- ValueError If the graph is not directed. ValueError If the `recursion_minimum_improvement` has an invalid value, i.e. NaN or infinity. ValueError If the `first_phase_minimum_improvement` has an invalid value, i.e. NaN or infinity.""" pass
Returns vector of vectors of communities for each layer of hierarchy minimizing undirected modularity.
Parameters
- recursion_minimum_improvement (Optional[float]): The minimum improvement to warrant another resursion round. By default, zero.
- first_phase_minimum_improvement (Optional[float]):
The minimum improvement to warrant another first phase iteration. By default,
0.00001
(not zero because of numerical instability). - patience (Optional[int]):
How many iterations of the first phase to wait for before stopping. By default,
5
. - random_state (Optional[int]): The random state to use to reproduce this modularity computation. By default, 42.
Raises
- ValueError: If the graph is not directed.
- ValueError: If the
recursion_minimum_improvement
has an invalid value, i.e. NaN or infinity. - ValueError: If the
first_phase_minimum_improvement
has an invalid value, i.e. NaN or infinity.
View Source
def get_directed_modularity_from_node_community_memberships(self, node_community_memberships: List[int]) -> float: """Returns the directed modularity of the graph from the given memberships. Parameters ---------- Raises ------- ValueError If the number of provided memberships does not match the number of nodes of the graph.""" pass
Returns the directed modularity of the graph from the given memberships.
Parameters
Raises
- ValueError: If the number of provided memberships does not match the number of nodes of the graph.
View Source
def get_undirected_modularity_from_node_community_memberships(self, node_community_memberships: List[int]) -> float: """Returns the undirected modularity of the graph from the given memberships. Parameters ---------- Raises ------- ValueError If the number of provided memberships does not match the number of nodes of the graph.""" pass
Returns the undirected modularity of the graph from the given memberships.
Parameters
Raises
- ValueError: If the number of provided memberships does not match the number of nodes of the graph.
View Source
def get_memory_stats(self) -> str: """Returns a string describing the memory usage of all the fields of all the structures used to store the current graph""" pass
Returns a string describing the memory usage of all the fields of all the structures used to store the current graph
View Source
def get_total_memory_used(self) -> int: """Returns how many bytes are currently used to store the given graph""" pass
Returns how many bytes are currently used to store the given graph
View Source
def get_nodes_total_memory_requirement(self) -> int: """Returns how many bytes are currently used to store the nodes""" pass
Returns how many bytes are currently used to store the nodes
View Source
def get_nodes_total_memory_requirement_human_readable(self) -> str: """Returns human readable amount of how many bytes are currently used to store the nodes""" pass
Returns human readable amount of how many bytes are currently used to store the nodes
View Source
def get_edges_total_memory_requirement(self) -> int: """Returns how many bytes are currently used to store the edges""" pass
Returns how many bytes are currently used to store the edges
View Source
def get_edges_total_memory_requirement_human_readable(self) -> str: """Returns human readable amount of how many bytes are currently used to store the edges""" pass
Returns human readable amount of how many bytes are currently used to store the edges
View Source
def get_edge_weights_total_memory_requirements(self) -> int: """Returns how many bytes are currently used to store the edge weights""" pass
Returns how many bytes are currently used to store the edge weights
View Source
def get_edge_weights_total_memory_requirements_human_readable(self) -> str: """Returns human readable amount of how many bytes are currently used to store the edge weights""" pass
Returns human readable amount of how many bytes are currently used to store the edge weights
View Source
def get_node_types_total_memory_requirements(self) -> int: """Returns how many bytes are currently used to store the node types""" pass
Returns how many bytes are currently used to store the node types
View Source
def get_node_types_total_memory_requirements_human_readable(self) -> str: """Returns human readable amount of how many bytes are currently used to store the node types""" pass
Returns human readable amount of how many bytes are currently used to store the node types
View Source
def get_edge_types_total_memory_requirements(self) -> int: """Returns how many bytes are currently used to store the edge types""" pass
Returns how many bytes are currently used to store the edge types
View Source
def get_edge_types_total_memory_requirements_human_readable(self) -> str: """Returns human readable amount of how many bytes are currently used to store the edge types""" pass
Returns human readable amount of how many bytes are currently used to store the edge types
View Source
def enable(self, vector_sources: Optional[bool], vector_destinations: Optional[bool], vector_cumulative_node_degrees: Optional[bool], vector_reciprocal_sqrt_degrees: Optional[bool]): """Enable extra perks that buys you time as you accept to spend more memory. Parameters ---------- vector_sources: Optional[bool] Whether to cache sources into a vector for faster walks. vector_destinations: Optional[bool] Whether to cache destinations into a vector for faster walks. vector_cumulative_node_degrees: Optional[bool] Whether to cache cumulative_node_degrees into a vector for faster walks. vector_reciprocal_sqrt_degrees: Optional[bool] Whether to cache reciprocal_sqrt_degrees into a vector for faster laplacian kernel computation.""" pass
Enable extra perks that buys you time as you accept to spend more memory.
Parameters
- vector_sources (Optional[bool]): Whether to cache sources into a vector for faster walks.
- vector_destinations (Optional[bool]): Whether to cache destinations into a vector for faster walks.
- vector_cumulative_node_degrees (Optional[bool]): Whether to cache cumulative_node_degrees into a vector for faster walks.
- vector_reciprocal_sqrt_degrees (Optional[bool]): Whether to cache reciprocal_sqrt_degrees into a vector for faster laplacian kernel computation.
View Source
def get_random_nodes(self, number_of_nodes_to_sample: int, random_state: int) -> np.ndarray: """Return random unique sorted numbers. Parameters ---------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to use to reproduce the sampling.""" pass
Return random unique sorted numbers.
Parameters
- number_of_nodes_to_sample (int): The number of nodes to sample.
- random_state (int): The random state to use to reproduce the sampling.
View Source
def get_breadth_first_search_random_nodes(self, number_of_nodes_to_sample: int, root_node: int) -> np.ndarray: """Return nodes sampled from the neighbourhood of given root nodes. Parameters ---------- number_of_nodes_to_sample: int The number of nodes to sample. root_node: int The root node from . Raises ------- ValueError If the number of requested nodes is higher than the number of nodes in the graph. ValueError If the given root node does not exist in the curret graph instance.""" pass
Return nodes sampled from the neighbourhood of given root nodes.
Parameters
- number_of_nodes_to_sample (int): The number of nodes to sample.
- root_node (int): The root node from .
Raises
- ValueError: If the number of requested nodes is higher than the number of nodes in the graph.
- ValueError: If the given root node does not exist in the curret graph instance.
View Source
def get_uniform_random_walk_random_nodes(self, node: int, random_state: int, walk_length: int, unique: Optional[bool]) -> np.ndarray: """Returns unique nodes sampled from uniform random walk. Parameters ---------- node: int Node from where to start the random walks. random_state: int the random_state to use for extracting the nodes and edges. walk_length: int Length of the random walk. unique: Optional[bool] Whether to make the sampled nodes unique. Raises ------- ValueError If the given node does not exist in the current slack.""" pass
Returns unique nodes sampled from uniform random walk.
Parameters
- node (int): Node from where to start the random walks.
- random_state (int): the random_state to use for extracting the nodes and edges.
- walk_length (int): Length of the random walk.
- unique (Optional[bool]): Whether to make the sampled nodes unique.
Raises
- ValueError: If the given node does not exist in the current slack.
View Source
def get_node_sampling_methods(self) -> List[str]: """Return list of the supported node sampling methods""" pass
Return list of the supported node sampling methods
View Source
def get_subsampled_nodes(self, number_of_nodes_to_sample: int, random_state: int, root_node: Optional[int], node_sampling_method: str, unique: Optional[bool]) -> np.ndarray: """Return subsampled nodes according to the given method and parameters. Parameters ---------- number_of_nodes_to_sample: int The number of nodes to sample. random_state: int The random state to reproduce the sampling. root_node: Optional[int] The (optional) root node to use to sample. In not provided, a random one is sampled. node_sampling_method: str The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based. unique: Optional[bool] Whether to make the sampled nodes unique. Raises ------- ValueError If the given node sampling method is not supported.""" pass
Return subsampled nodes according to the given method and parameters.
Parameters
- number_of_nodes_to_sample (int): The number of nodes to sample.
- random_state (int): The random state to reproduce the sampling.
- root_node (Optional[int]): The (optional) root node to use to sample. In not provided, a random one is sampled.
- node_sampling_method (str): The method to use to sample the nodes. Can either be random nodes, breath first search-based or uniform random walk-based.
- unique (Optional[bool]): Whether to make the sampled nodes unique.
Raises
- ValueError: If the given node sampling method is not supported.
View Source
def is_compatible(self, other: Graph) -> bool: """Return true if the graphs are compatible. Parameters ---------- other: Graph The other graph. Raises ------- ValueError If a graph is directed and the other is undirected. ValueError If one of the two graphs has edge weights and the other does not. ValueError If one of the two graphs has node types and the other does not. ValueError If one of the two graphs has edge types and the other does not.""" pass
Return true if the graphs are compatible.
Parameters
- other (Graph): The other graph.
Raises
- ValueError: If a graph is directed and the other is undirected.
- ValueError: If one of the two graphs has edge weights and the other does not.
- ValueError: If one of the two graphs has node types and the other does not.
- ValueError: If one of the two graphs has edge types and the other does not.
View Source
def has_same_adjacency_matrix(self, other: Graph) -> bool: """Return true if the graphs share the same adjacency matrix. Parameters ---------- other: Graph The other graph.""" pass
Return true if the graphs share the same adjacency matrix.
Parameters
- other (Graph): The other graph.
View Source
def validate_node_id(self, node_id: int) -> int: """Validates provided node ID. Parameters ---------- node_id: int node ID to validate. Raises ------- ValueError If the given node ID does not exists in the graph.""" pass
Validates provided node ID.
Parameters
- node_id (int): node ID to validate.
Raises
- ValueError: If the given node ID does not exists in the graph.
View Source
def validate_node_ids(self, node_ids: List[int]) -> np.ndarray: """Validates all provided node IDs. Parameters ---------- node_ids: List[int] node IDs to validate. Raises ------- ValueError If any of the given node ID does not exists in the graph.""" pass
Validates all provided node IDs.
Parameters
- node_ids (List[int]): node IDs to validate.
Raises
- ValueError: If any of the given node ID does not exists in the graph.
View Source
def validate_edge_id(self, edge_id: int) -> int: """Validates provided edge ID. Parameters ---------- edge_id: int Edge ID to validate. Raises ------- ValueError If the given edge ID does not exists in the graph.""" pass
Validates provided edge ID.
Parameters
- edge_id (int): Edge ID to validate.
Raises
- ValueError: If the given edge ID does not exists in the graph.
View Source
def validate_edge_ids(self, edge_ids: List[int]) -> np.ndarray: """Validates provided edge IDs. Parameters ---------- edge_ids: List[int] Edge IDs to validate. Raises ------- ValueError If any of the given edge ID does not exists in the graph.""" pass
Validates provided edge IDs.
Parameters
- edge_ids (List[int]): Edge IDs to validate.
Raises
- ValueError: If any of the given edge ID does not exists in the graph.
View Source
def must_not_contain_unknown_node_types(self): """Raises an error if the graph contains unknown node types. Raises ------- ValueError If the graph does not contain node types. ValueError If the graph contains unknown node types.""" pass
Raises an error if the graph contains unknown node types.
Raises
- ValueError: If the graph does not contain node types.
- ValueError: If the graph contains unknown node types.
View Source
def must_not_contain_unknown_edge_types(self): """Raises an error if the graph contains unknown edge types. Raises ------- ValueError If the graph does not contain edge types. ValueError If the graph contains unknown edge types.""" pass
Raises an error if the graph contains unknown edge types.
Raises
- ValueError: If the graph does not contain edge types.
- ValueError: If the graph contains unknown edge types.
View Source
def validate_node_type_id(self, node_type_id: Optional[int]) -> Optional[int]: """Validates provided node type ID. Parameters ---------- node_type_id: Optional[int] Node type ID to validate. Raises ------- ValueError If the given node type ID does not exists in the graph.""" pass
Validates provided node type ID.
Parameters
- node_type_id (Optional[int]): Node type ID to validate.
Raises
- ValueError: If the given node type ID does not exists in the graph.
View Source
def validate_node_type_ids(self, node_type_ids: List[Optional[int]]) -> List[Optional[int]]: """Validates provided node type IDs. Parameters ---------- node_type_ids: List[Optional[int]] Vector of node type IDs to validate. Raises ------- ValueError If there are no node types in the graph.""" pass
Validates provided node type IDs.
Parameters
- node_type_ids (List[Optional[int]]): Vector of node type IDs to validate.
Raises
- ValueError: If there are no node types in the graph.
View Source
def validate_edge_type_id(self, edge_type_id: Optional[int]) -> Optional[int]: """Validates provided edge type ID. Parameters ---------- edge_type_id: Optional[int] edge type ID to validate. Raises ------- ValueError If the given edge type ID does not exists in the graph.""" pass
Validates provided edge type ID.
Parameters
- edge_type_id (Optional[int]): edge type ID to validate.
Raises
- ValueError: If the given edge type ID does not exists in the graph.
View Source
def validate_edge_type_ids(self, edge_type_ids: List[Optional[int]]) -> List[Optional[int]]: """Validates provided edge type IDs. Parameters ---------- edge_type_ids: List[Optional[int]] Vector of edge type IDs to validate. Raises ------- ValueError If there are no edge types in the graph.""" pass
Validates provided edge type IDs.
Parameters
- edge_type_ids (List[Optional[int]]): Vector of edge type IDs to validate.
Raises
- ValueError: If there are no edge types in the graph.
View Source
def must_be_undirected(self): """Raises an error if the graph does not have edge types. Raises ------- ValueError If the graph is directed.""" pass
Raises an error if the graph does not have edge types.
Raises
- ValueError: If the graph is directed.
View Source
def must_be_multigraph(self): """Raises an error if the graph does not have edge types. Raises ------- ValueError If the graph is not a multigraph.""" pass
Raises an error if the graph does not have edge types.
Raises
- ValueError: If the graph is not a multigraph.
View Source
def must_not_be_multigraph(self): """Raises an error if the graph does not have edge types. Raises ------- ValueError If the graph is a multigraph.""" pass
Raises an error if the graph does not have edge types.
Raises
- ValueError: If the graph is a multigraph.
View Source
def must_contain_identity_matrix(self): """Raises an error if the graph does not include the identity matrix. Raises ------- ValueError If the graph is a multigraph.""" pass
Raises an error if the graph does not include the identity matrix.
Raises
- ValueError: If the graph is a multigraph.
View Source
def must_not_contain_weighted_singleton_nodes(self): """Raises an error if the graph contains zero weighted degree. Raises ------- ValueError If the graph does not have edges.""" pass
Raises an error if the graph contains zero weighted degree.
Raises
- ValueError: If the graph does not have edges.
View Source
def must_have_edges(self): """Raises an error if the graph has a maximal weighted Raises ------- ValueError If the graph does not have edges.""" pass
Raises an error if the graph has a maximal weighted
Raises
- ValueError: If the graph does not have edges.
View Source
def must_have_nodes(self): """Raises an error if the graph does not have any node. Raises ------- ValueError If the graph does not have nodes.""" pass
Raises an error if the graph does not have any node.
Raises
- ValueError: If the graph does not have nodes.
View Source
def must_be_connected(self): """Raises an error if the graph is not connected. Raises ------- ValueError If the graph is not connected.""" pass
Raises an error if the graph is not connected.
Raises
- ValueError: If the graph is not connected.
View Source
def get_number_of_triangles(self, normalize: Optional[bool], low_centrality: Optional[int], verbose: Optional[bool]) -> int: """Returns total number of triangles ignoring the weights. The method dispatches the fastest method according to the current graph instance. Specifically: - For directed graphs it will use the naive algorithm. - For undirected graphs it will use Bader's version. Parameters ---------- normalize: Optional[bool] Whether to normalize the number of triangles. low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass
Returns total number of triangles ignoring the weights.
The method dispatches the fastest method according to the current graph instance. Specifically:
- For directed graphs it will use the naive algorithm.
- For undirected graphs it will use Bader's version.
Parameters
- normalize (Optional[bool]): Whether to normalize the number of triangles.
- low_centrality (Optional[int]): The threshold over which to switch to parallel matryoshka. By default 50.
- verbose (Optional[bool]): Whether to show a loading bar.
View Source
def get_triads_number(self) -> int: """Returns total number of triads in the graph without taking into account weights""" pass
Returns total number of triads in the graph without taking into account weights
View Source
def get_weighted_triads_number(self) -> float: """Returns total number of triads in the weighted graph""" pass
Returns total number of triads in the weighted graph
View Source
def get_transitivity(self, low_centrality: Optional[int], verbose: Optional[bool]) -> float: """Returns transitivity of the graph without taking into account weights. Parameters ---------- low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass
Returns transitivity of the graph without taking into account weights.
Parameters
- low_centrality (Optional[int]): The threshold over which to switch to parallel matryoshka. By default 50.
- verbose (Optional[bool]): Whether to show a loading bar.
View Source
def get_number_of_triangles_per_node(self, normalize: Optional[bool], low_centrality: Optional[int], verbose: Optional[bool]) -> np.ndarray: """Returns number of triangles in the graph without taking into account the weights. The method dispatches the fastest method according to the current graph instance. Specifically: - For directed graphs it will use the naive algorithm. - For undirected graphs it will use Bader's version. Parameters ---------- normalize: Optional[bool] Whether to normalize the number of triangles. low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass
Returns number of triangles in the graph without taking into account the weights.
The method dispatches the fastest method according to the current graph instance. Specifically:
- For directed graphs it will use the naive algorithm.
- For undirected graphs it will use Bader's version.
Parameters
- normalize (Optional[bool]): Whether to normalize the number of triangles.
- low_centrality (Optional[int]): The threshold over which to switch to parallel matryoshka. By default 50.
- verbose (Optional[bool]): Whether to show a loading bar.
View Source
def get_clustering_coefficient_per_node(self, low_centrality: Optional[int], verbose: Optional[bool]) -> np.ndarray: """Returns clustering coefficients for all nodes in the graph. Parameters ---------- low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass
Returns clustering coefficients for all nodes in the graph.
Parameters
- low_centrality (Optional[int]): The threshold over which to switch to parallel matryoshka. By default 50.
- verbose (Optional[bool]): Whether to show a loading bar.
View Source
def get_clustering_coefficient(self, low_centrality: Optional[int], verbose: Optional[bool]) -> float: """Returns the graph clustering coefficient. Parameters ---------- low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass
Returns the graph clustering coefficient.
Parameters
- low_centrality (Optional[int]): The threshold over which to switch to parallel matryoshka. By default 50.
- verbose (Optional[bool]): Whether to show a loading bar.
View Source
def get_average_clustering_coefficient(self, low_centrality: Optional[int], verbose: Optional[bool]) -> float: """Returns the graph average clustering coefficient. Parameters ---------- low_centrality: Optional[int] The threshold over which to switch to parallel matryoshka. By default 50. verbose: Optional[bool] Whether to show a loading bar.""" pass
Returns the graph average clustering coefficient.
Parameters
- low_centrality (Optional[int]): The threshold over which to switch to parallel matryoshka. By default 50.
- verbose (Optional[bool]): Whether to show a loading bar.
View Source
def get_okapi_bm25_node_feature_propagation(self, features: List[List[float]], iterations: Optional[int], maximal_distance: Optional[int], k1: Optional[float], b: Optional[float], include_central_node: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Returns okapi node features propagation within given maximal distance. Parameters ---------- features: List[Optional[List[float]]] The features to propagate. Use None to represent eventual unknown features. iterations: Optional[int] The number of iterations to execute. By default one. maximal_distance: Optional[int] The distance to consider for the cooccurrences. The default value is 3. k1: Optional[float] The k1 parameter from okapi. Tipicaly between 1.2 and 2.0. It can be seen as a smoothing. b: Optional[float] The b parameter from okapi. Tipicaly 0.75. include_central_node: Optional[bool] Whether to include the central node. By default true. verbose: Optional[bool] Whether to show loading bar. Raises ------- ValueError If the graph does not have node types.""" pass
Returns okapi node features propagation within given maximal distance.
Parameters
- features (List[Optional[List[float]]]): The features to propagate. Use None to represent eventual unknown features.
- iterations (Optional[int]): The number of iterations to execute. By default one.
- maximal_distance (Optional[int]): The distance to consider for the cooccurrences. The default value is 3.
- k1 (Optional[float]): The k1 parameter from okapi. Tipicaly between 1.2 and 2.0. It can be seen as a smoothing.
- b (Optional[float]): The b parameter from okapi. Tipicaly 0.75.
- include_central_node (Optional[bool]): Whether to include the central node. By default true.
- verbose (Optional[bool]): Whether to show loading bar.
Raises
- ValueError: If the graph does not have node types.
View Source
def get_okapi_bm25_node_label_propagation(self, iterations: Optional[int], maximal_distance: Optional[int], k1: Optional[float], b: Optional[float], verbose: Optional[bool]) -> np.ndarray: """Returns okapi node label propagation within given maximal distance. Parameters ---------- iterations: Optional[int] The number of iterations to execute. By default one. maximal_distance: Optional[int] The distance to consider for the cooccurrences. The default value is 3. k1: Optional[float] The k1 parameter from okapi. Tipicaly between 1.2 and 2.0. It can be seen as a smoothing. b: Optional[float] The b parameter from okapi. Tipicaly 0.75. verbose: Optional[bool] Whether to show loading bar. Raises ------- ValueError If the graph does not have node types.""" pass
Returns okapi node label propagation within given maximal distance.
Parameters
- iterations (Optional[int]): The number of iterations to execute. By default one.
- maximal_distance (Optional[int]): The distance to consider for the cooccurrences. The default value is 3.
- k1 (Optional[float]): The k1 parameter from okapi. Tipicaly between 1.2 and 2.0. It can be seen as a smoothing.
- b (Optional[float]): The b parameter from okapi. Tipicaly 0.75.
- verbose (Optional[bool]): Whether to show loading bar.
Raises
- ValueError: If the graph does not have node types.
View Source
def get_unchecked_edge_weight_from_edge_id(self, edge_id: int) -> Optional[float]: """Returns option with the weight of the given edge id. This method will raise a panic if the given edge ID is higher than the number of edges in the graph. Additionally, it will simply return None if there are no graph weights. Parameters ---------- edge_id: int The edge whose edge weight is to be returned. Safety ------ If the given edge ID does not exists in the graph this method will panic.""" pass
Returns option with the weight of the given edge id.
This method will raise a panic if the given edge ID is higher than the number of edges in the graph. Additionally, it will simply return None if there are no graph weights.
Parameters
- edge_id (int): The edge whose edge weight is to be returned.
Safety
If the given edge ID does not exists in the graph this method will panic.
View Source
def get_unchecked_edge_weight_from_node_ids(self, src: int, dst: int) -> float: """Returns option with the weight of the given node ids. This method will raise a panic if the given node IDs are higher than the number of nodes in the graph. Parameters ---------- src: int The source node ID. dst: int The destination node ID. Safety ------ If either of the two given node IDs does not exists in the graph.""" pass
Returns option with the weight of the given node ids.
This method will raise a panic if the given node IDs are higher than the number of nodes in the graph.
Parameters
- src (int): The source node ID.
- dst (int): The destination node ID.
Safety
If either of the two given node IDs does not exists in the graph.
View Source
def get_unchecked_node_id_from_node_name(self, node_name: str) -> int: """Returns node id from given node name raising a panic if used unproperly. Parameters ---------- node_name: str The node name whose node ID is to be returned. Safety ------ If the given node name does not exists in the considered graph the method will panic.""" pass
Returns node id from given node name raising a panic if used unproperly.
Parameters
- node_name (str): The node name whose node ID is to be returned.
Safety
If the given node name does not exists in the considered graph the method will panic.
View Source
def get_unchecked_edge_type_id_from_edge_type_name(self, edge_type_name: str) -> Optional[int]: """Return edge type ID corresponding to the given edge type name. Parameters ---------- edge_type_name: str The edge type name whose edge type ID is to be returned. Safety ------ If the given edge type name does not exists in the considered graph the method will panic.""" pass
Return edge type ID corresponding to the given edge type name.
Parameters
- edge_type_name (str): The edge type name whose edge type ID is to be returned.
Safety
If the given edge type name does not exists in the considered graph the method will panic.
View Source
def get_unchecked_edge_type_name_from_edge_type_id(self, edge_type_id: Optional[int]) -> Optional[str]: """Return edge type ID corresponding to the given edge type name raising panic if edge type ID does not exists in current graph. Parameters ---------- edge_type_id: Optional[int] The edge type naIDme whose edge type name is to be returned. Safety ------ If the given edge type ID does not exist in the graph the method will panic.""" pass
Return edge type ID corresponding to the given edge type name raising panic if edge type ID does not exists in current graph.
Parameters
- edge_type_id (Optional[int]): The edge type naIDme whose edge type name is to be returned.
Safety
If the given edge type ID does not exist in the graph the method will panic.
View Source
def get_unchecked_edge_count_from_edge_type_id(self, edge_type: Optional[int]) -> int: """Return number of edges of the given edge type without checks. Parameters ---------- edge_type: Optional[int] The edge type to retrieve count of. Safety ------ If the given edge type ID does not exist in the graph the method will panic.""" pass
Return number of edges of the given edge type without checks.
Parameters
- edge_type (Optional[int]): The edge type to retrieve count of.
Safety
If the given edge type ID does not exist in the graph the method will panic.
View Source
def get_unchecked_edge_id_from_node_ids_and_edge_type_id(self, src: int, dst: int, edge_type: Optional[int]) -> int: """Return edge ID without any checks for given tuple of nodes and edge type. Parameters ---------- src: int Source node of the edge. dst: int Destination node of the edge. edge_type: Optional[int] Edge Type of the edge. Safety ------ If the given node IDs or edge type does not exists in the graph this method will panic.""" pass
Return edge ID without any checks for given tuple of nodes and edge type.
Parameters
- src (int): Source node of the edge.
- dst (int): Destination node of the edge.
- edge_type (Optional[int]): Edge Type of the edge.
Safety
If the given node IDs or edge type does not exists in the graph this method will panic.
View Source
def get_unchecked_minmax_edge_ids_from_node_ids(self, src: int, dst: int) -> Tuple[int, int]: """Return range of outbound edges IDs for all the edges bewteen the given source and destination nodes. This operation is meaningfull only in a multigraph. Parameters ---------- src: int Source node. dst: int Destination node. Safety ------ If the given node type IDs do not exist in the graph this method will panic.""" pass
Return range of outbound edges IDs for all the edges bewteen the given source and destination nodes. This operation is meaningfull only in a multigraph.
Parameters
- src (int): Source node.
- dst (int): Destination node.
Safety
If the given node type IDs do not exist in the graph this method will panic.
View Source
def get_unchecked_node_ids_from_edge_id(self, edge_id: int) -> Tuple[int, int]: """Returns node IDs corresponding to given edge ID. The method will panic if the given edge ID does not exists in the current graph instance. Parameters ---------- edge_id: int The edge ID whose source and destination node IDs are to e retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass
Returns node IDs corresponding to given edge ID.
The method will panic if the given edge ID does not exists in the current graph instance.
Parameters
- edge_id (int): The edge ID whose source and destination node IDs are to e retrieved.
Safety
If the given edge ID does not exist in the current graph the method will raise a panic.
View Source
def get_unchecked_node_names_from_edge_id(self, edge_id: int) -> Tuple[str, str]: """Returns node names corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source and destination node IDs are to e retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass
Returns node names corresponding to given edge ID.
Parameters
- edge_id (int): The edge ID whose source and destination node IDs are to e retrieved.
Safety
If the given edge ID does not exist in the current graph the method will raise a panic.
View Source
def get_unchecked_source_node_id_from_edge_id(self, edge_id: int) -> int: """Returns the source of given edge id without making any boundary check. Parameters ---------- edge_id: int The edge ID whose source is to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will cause an out of bounds.""" pass
Returns the source of given edge id without making any boundary check.
Parameters
- edge_id (int): The edge ID whose source is to be retrieved.
Safety
If the given edge ID does not exist in the current graph the method will cause an out of bounds.
View Source
def get_unchecked_destination_node_id_from_edge_id(self, edge_id: int) -> int: """Returns the destination of given edge id without making any boundary check. Parameters ---------- edge_id: int The edge ID whose destination is to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will cause an out of bounds.""" pass
Returns the destination of given edge id without making any boundary check.
Parameters
- edge_id (int): The edge ID whose destination is to be retrieved.
Safety
If the given edge ID does not exist in the current graph the method will cause an out of bounds.
View Source
def get_source_node_id_from_edge_id(self, edge_id: int) -> int: """Returns source node ID corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source node ID is to be retrieved. Raises ------- ValueError If the given edge ID does not exist in the current graph.""" pass
Returns source node ID corresponding to given edge ID.
Parameters
- edge_id (int): The edge ID whose source node ID is to be retrieved.
Raises
- ValueError: If the given edge ID does not exist in the current graph.
View Source
def get_destination_node_id_from_edge_id(self, edge_id: int) -> int: """Returns destination node ID corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose destination node ID is to be retrieved. Raises ------- ValueError If the given edge ID does not exist in the current graph.""" pass
Returns destination node ID corresponding to given edge ID.
Parameters
- edge_id (int): The edge ID whose destination node ID is to be retrieved.
Raises
- ValueError: If the given edge ID does not exist in the current graph.
View Source
def get_unchecked_source_node_name_from_edge_id(self, edge_id: int) -> str: """Returns source node name corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source node name is to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass
Returns source node name corresponding to given edge ID.
Parameters
- edge_id (int): The edge ID whose source node name is to be retrieved.
Safety
If the given edge ID does not exist in the current graph the method will raise a panic.
View Source
def get_unchecked_destination_node_name_from_edge_id(self, edge_id: int) -> str: """Returns destination node name corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose destination node name is to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass
Returns destination node name corresponding to given edge ID.
Parameters
- edge_id (int): The edge ID whose destination node name is to be retrieved.
Safety
If the given edge ID does not exist in the current graph the method will raise a panic.
View Source
def get_source_node_name_from_edge_id(self, edge_id: int) -> str: """Returns source node name corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source node name is to be retrieved. Raises -------""" pass
Returns source node name corresponding to given edge ID.
Parameters
- edge_id (int): The edge ID whose source node name is to be retrieved.
- Raises
View Source
def get_destination_node_name_from_edge_id(self, edge_id: int) -> str: """Returns destination node name corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose destination node name is to be retrieved. Raises -------""" pass
Returns destination node name corresponding to given edge ID.
Parameters
- edge_id (int): The edge ID whose destination node name is to be retrieved.
- Raises
View Source
def get_node_names_from_edge_id(self, edge_id: int) -> Tuple[str, str]: """Returns node names corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source and destination node IDs are to e retrieved.""" pass
Returns node names corresponding to given edge ID.
Parameters
- edge_id (int): The edge ID whose source and destination node IDs are to e retrieved.
View Source
def get_node_ids_from_edge_id(self, edge_id: int) -> Tuple[int, int]: """Returns node names corresponding to given edge ID. Parameters ---------- edge_id: int The edge ID whose source and destination node IDs are to e retrieved.""" pass
Returns node names corresponding to given edge ID.
Parameters
- edge_id (int): The edge ID whose source and destination node IDs are to e retrieved.
View Source
def get_unchecked_edge_id_from_node_ids(self, src: int, dst: int) -> int: """Returns edge ID corresponding to given source and destination node IDs. The method will panic if the given source and destination node IDs do not correspond to an edge in this graph instance. Parameters ---------- src: int The source node ID. dst: int The destination node ID. Safety ------ If any of the given node IDs do not exist in the graph the method will panic.""" pass
Returns edge ID corresponding to given source and destination node IDs.
The method will panic if the given source and destination node IDs do not correspond to an edge in this graph instance.
Parameters
- src (int): The source node ID.
- dst (int): The destination node ID.
Safety
If any of the given node IDs do not exist in the graph the method will panic.
View Source
def get_edge_id_from_node_ids(self, src: int, dst: int) -> int: """Returns edge ID corresponding to given source and destination node IDs. Parameters ---------- src: int The source node ID. dst: int The destination node ID.""" pass
Returns edge ID corresponding to given source and destination node IDs.
Parameters
- src (int): The source node ID.
- dst (int): The destination node ID.
View Source
def get_unchecked_unique_source_node_id(self, source_id: int) -> int: """Returns edge ID corresponding to given source and destination node IDs. Parameters ---------- source_id: int The source node ID. Safety ------ If the given source node ID does not exist in the current graph the method will panic.""" pass
Returns edge ID corresponding to given source and destination node IDs.
Parameters
- source_id (int): The source node ID.
Safety
If the given source node ID does not exist in the current graph the method will panic.
View Source
def get_unchecked_node_ids_and_edge_type_id_from_edge_id(self, edge_id: int) -> Tuple[int, int, Optional[int]]: """Return the src, dst, edge type of a given edge ID. This method will raise a panic when an improper configuration is used. Parameters ---------- edge_id: int The edge ID whose source, destination and edge type are to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass
Return the src, dst, edge type of a given edge ID.
This method will raise a panic when an improper configuration is used.
Parameters
- edge_id (int): The edge ID whose source, destination and edge type are to be retrieved.
Safety
If the given edge ID does not exist in the current graph the method will raise a panic.
View Source
def get_node_ids_and_edge_type_id_from_edge_id(self, edge_id: int) -> Tuple[int, int, Optional[int]]: """Return the src, dst, edge type of a given edge ID. Parameters ---------- edge_id: int The edge ID whose source, destination and edge type are to be retrieved.""" pass
Return the src, dst, edge type of a given edge ID.
Parameters
- edge_id (int): The edge ID whose source, destination and edge type are to be retrieved.
View Source
def get_unchecked_node_ids_and_edge_type_id_and_edge_weight_from_edge_id(self, edge_id: int) -> Tuple[int, int, Optional[int], Optional[float]]: """Return the src, dst, edge type and weight of a given edge ID. This method will raise a panic when an improper configuration is used. Parameters ---------- edge_id: int The edge ID whose source, destination, edge type and weight are to be retrieved. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass
Return the src, dst, edge type and weight of a given edge ID.
This method will raise a panic when an improper configuration is used.
Parameters
- edge_id (int): The edge ID whose source, destination, edge type and weight are to be retrieved.
Safety
If the given edge ID does not exist in the current graph the method will raise a panic.
View Source
def get_node_ids_and_edge_type_id_and_edge_weight_from_edge_id(self, edge_id: int) -> Tuple[int, int, Optional[int], Optional[float]]: """Return the src, dst, edge type and weight of a given edge ID. Parameters ---------- edge_id: int The edge ID whose source, destination, edge type and weight are to be retrieved.""" pass
Return the src, dst, edge type and weight of a given edge ID.
Parameters
- edge_id (int): The edge ID whose source, destination, edge type and weight are to be retrieved.
View Source
def get_top_k_central_node_ids(self, k: int) -> np.ndarray: """Return vector with unweighted top k central node Ids. If the k passed is bigger than the number of nodes this method will return all the nodes in the graph. Parameters ---------- k: int Number of central nodes to extract. Raises ------- ValueError If the given value k is zero. ValueError If the graph has no nodes.""" pass
Return vector with unweighted top k central node Ids.
If the k passed is bigger than the number of nodes this method will return all the nodes in the graph.
Parameters
- k (int): Number of central nodes to extract.
Raises
- ValueError: If the given value k is zero.
- ValueError: If the graph has no nodes.
View Source
def get_weighted_top_k_central_node_ids(self, k: int) -> np.ndarray: """Return vector with weighted top k central node Ids. If the k passed is bigger than the number of nodes this method will return all the nodes in the graph. Parameters ---------- k: int Number of central nodes to extract. Raises ------- ValueError If the current graph instance does not contain edge weights. ValueError If the given value k is zero.""" pass
Return vector with weighted top k central node Ids.
If the k passed is bigger than the number of nodes this method will return all the nodes in the graph.
Parameters
- k (int): Number of central nodes to extract.
Raises
- ValueError: If the current graph instance does not contain edge weights.
- ValueError: If the given value k is zero.
View Source
def get_unchecked_node_degree_from_node_id(self, node_id: int) -> int: """Returns the number of outbound neighbours of given node. Parameters ---------- node_id: int Integer ID of the node. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass
Returns the number of outbound neighbours of given node.
Parameters
- node_id (int): Integer ID of the node.
Safety
If the given node ID does not exist in the current graph the method will raise a panic.
View Source
def get_unchecked_weighted_node_degree_from_node_id(self, node_id: int) -> float: """Returns the weighted sum of outbound neighbours of given node. The method will panic if the given node id is higher than the number of nodes in the graph. Parameters ---------- node_id: int Integer ID of the node. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass
Returns the weighted sum of outbound neighbours of given node.
The method will panic if the given node id is higher than the number of nodes in the graph.
Parameters
- node_id (int): Integer ID of the node.
Safety
If the given node ID does not exist in the current graph the method will raise a panic.
View Source
def get_node_degree_from_node_id(self, node_id: int) -> int: """Returns the number of outbound neighbours of given node ID. Parameters ---------- node_id: int Integer ID of the node.""" pass
Returns the number of outbound neighbours of given node ID.
Parameters
- node_id (int): Integer ID of the node.
View Source
def get_unchecked_comulative_node_degree_from_node_id(self, node_id: int) -> int: """Returns the comulative node degree up to the given node. Parameters ---------- node_id: int Integer ID of the node. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass
Returns the comulative node degree up to the given node.
Parameters
- node_id (int): Integer ID of the node.
Safety
If the given node ID does not exist in the current graph the method will raise a panic.
View Source
def get_comulative_node_degree_from_node_id(self, node_id: int) -> int: """Returns the comulative node degree up to the given node. Parameters ---------- node_id: int Integer ID of the node.""" pass
Returns the comulative node degree up to the given node.
Parameters
- node_id (int): Integer ID of the node.
View Source
def get_unchecked_reciprocal_sqrt_degree_from_node_id(self, node_id: int) -> float: """Returns the reciprocal squared root node degree up to the given node. Parameters ---------- node_id: int Integer ID of the node. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass
Returns the reciprocal squared root node degree up to the given node.
Parameters
- node_id (int): Integer ID of the node.
Safety
If the given node ID does not exist in the current graph the method will raise a panic.
View Source
def get_reciprocal_sqrt_degree_from_node_id(self, node_id: int) -> float: """Returns the reciprocal squared root node degree up to the given node. Parameters ---------- node_id: int Integer ID of the node.""" pass
Returns the reciprocal squared root node degree up to the given node.
Parameters
- node_id (int): Integer ID of the node.
View Source
def get_unchecked_reciprocal_sqrt_degrees_from_node_ids(self, node_ids: List[int]) -> np.ndarray: """Return vector with reciprocal squared root degree of the provided nodes. Parameters ---------- node_ids: List[int] The vector of node IDs whose reciprocal squared root degree is to be retrieved. Safety ------ This method makes the assumption that the provided node IDs exist in the graph, that is they are not higher than the number of nodes in the graph.""" pass
Return vector with reciprocal squared root degree of the provided nodes.
Parameters
- node_ids (List[int]): The vector of node IDs whose reciprocal squared root degree is to be retrieved.
Safety
This method makes the assumption that the provided node IDs exist in the graph, that is they are not higher than the number of nodes in the graph.
View Source
def get_weighted_node_degree_from_node_id(self, node_id: int) -> float: """Returns the weighted sum of outbound neighbours of given node ID. Parameters ---------- node_id: int Integer ID of the node.""" pass
Returns the weighted sum of outbound neighbours of given node ID.
Parameters
- node_id (int): Integer ID of the node.
View Source
def get_node_degree_from_node_name(self, node_name: str) -> int: """Returns the number of outbound neighbours of given node name. Parameters ---------- node_name: str Integer ID of the node. Raises ------- ValueError If the given node name does not exist in the graph.""" pass
Returns the number of outbound neighbours of given node name.
Parameters
- node_name (str): Integer ID of the node.
Raises
- ValueError: If the given node name does not exist in the graph.
View Source
def get_top_k_central_node_names(self, k: int) -> List[str]: """Return vector with top k central node names. Parameters ---------- k: int Number of central nodes to extract.""" pass
Return vector with top k central node names.
Parameters
- k (int): Number of central nodes to extract.
View Source
def get_unchecked_node_type_id_from_node_id(self, node_id: int) -> Optional[List[int]]: """Returns option with vector of node types of given node. This method will panic if the given node ID is greater than the number of nodes in the graph. Furthermore, if the graph does NOT have node types, it will NOT return neither an error or a panic. Parameters ---------- node_id: int node whose node type is to be returned. Safety ------ Even though the method will return an option when the node types are not available for the current graph, the behaviour is undefined.""" pass
Returns option with vector of node types of given node.
This method will panic if the given node ID is greater than the number of nodes in the graph. Furthermore, if the graph does NOT have node types, it will NOT return neither an error or a panic.
Parameters
- node_id (int): node whose node type is to be returned.
Safety
Even though the method will return an option when the node types are not available for the current graph, the behaviour is undefined.
View Source
def get_node_type_ids_from_node_id(self, node_id: int) -> Optional[List[int]]: """Returns node type of given node. Parameters ---------- node_id: int node whose node type is to be returned.""" pass
Returns node type of given node.
Parameters
- node_id (int): node whose node type is to be returned.
View Source
def get_unchecked_edge_type_id_from_edge_id(self, edge_id: int) -> Optional[int]: """Returns edge type of given edge. This method will panic if the given edge ID is greater than the number of edges in the graph. Furthermore, if the graph does NOT have edge types, it will NOT return neither an error or a panic. Parameters ---------- edge_id: int edge whose edge type is to be returned. Safety ------ If the given edge ID does not exist in the current graph the method will raise a panic.""" pass
Returns edge type of given edge.
This method will panic if the given edge ID is greater than the number of edges in the graph. Furthermore, if the graph does NOT have edge types, it will NOT return neither an error or a panic.
Parameters
- edge_id (int): edge whose edge type is to be returned.
Safety
If the given edge ID does not exist in the current graph the method will raise a panic.
View Source
def get_edge_type_id_from_edge_id(self, edge_id: int) -> Optional[int]: """Returns edge type of given edge. Parameters ---------- edge_id: int edge whose edge type is to be returned.""" pass
Returns edge type of given edge.
Parameters
- edge_id (int): edge whose edge type is to be returned.
View Source
def get_unchecked_node_type_names_from_node_id(self, node_id: int) -> Optional[List[str]]: """Returns result of option with the node type of the given node id. Parameters ---------- node_id: int The node ID whose node types are to be returned. Safety ------ This method will return an iterator of None values when the graph does not contain node types.""" pass
Returns result of option with the node type of the given node id.
Parameters
- node_id (int): The node ID whose node types are to be returned.
Safety
This method will return an iterator of None values when the graph does not contain node types.
View Source
def get_node_type_names_from_node_id(self, node_id: int) -> Optional[List[str]]: """Returns result of option with the node type of the given node id. Parameters ---------- node_id: int The node ID whose node types are to be returned. Raises ------- ValueError If the node types are not available for the current graph instance.""" pass
Returns result of option with the node type of the given node id.
Parameters
- node_id (int): The node ID whose node types are to be returned.
Raises
- ValueError: If the node types are not available for the current graph instance.
View Source
def get_node_type_names_from_node_name(self, node_name: str) -> Optional[List[str]]: """Returns result of option with the node type of the given node name. Parameters ---------- node_name: str The node name whose node types are to be returned.""" pass
Returns result of option with the node type of the given node name.
Parameters
- node_name (str): The node name whose node types are to be returned.
View Source
def get_edge_type_name_from_edge_id(self, edge_id: int) -> Optional[str]: """Returns option with the edge type of the given edge id. Parameters ---------- edge_id: int The edge ID whose edge type is to be returned.""" pass
Returns option with the edge type of the given edge id.
Parameters
- edge_id (int): The edge ID whose edge type is to be returned.
View Source
def get_edge_type_name_from_edge_type_id(self, edge_type_id: int) -> str: """Return edge type name of given edge type. Parameters ---------- edge_type_id: int Id of the edge type.""" pass
Return edge type name of given edge type.
Parameters
- edge_type_id (int): Id of the edge type.
View Source
def get_edge_weight_from_edge_id(self, edge_id: int) -> float: """Returns weight of the given edge id. Parameters ---------- edge_id: int The edge ID whose weight is to be returned.""" pass
Returns weight of the given edge id.
Parameters
- edge_id (int): The edge ID whose weight is to be returned.
View Source
def get_edge_weight_from_node_ids(self, src: int, dst: int) -> float: """Returns weight of the given node ids. Parameters ---------- src: int The node ID of the source node. dst: int The node ID of the destination node.""" pass
Returns weight of the given node ids.
Parameters
- src (int): The node ID of the source node.
- dst (int): The node ID of the destination node.
View Source
def get_edge_weight_from_node_ids_and_edge_type_id(self, src: int, dst: int, edge_type: Optional[int]) -> float: """Returns weight of the given node ids and edge type. Parameters ---------- src: int The node ID of the source node. dst: int The node ID of the destination node. edge_type: Optional[int] The edge type ID of the edge.""" pass
Returns weight of the given node ids and edge type.
Parameters
- src (int): The node ID of the source node.
- dst (int): The node ID of the destination node.
- edge_type (Optional[int]): The edge type ID of the edge.
View Source
def get_edge_weight_from_node_names_and_edge_type_name(self, src: str, dst: str, edge_type: Optional[str]) -> float: """Returns weight of the given node names and edge type. Parameters ---------- src: str The node name of the source node. dst: str The node name of the destination node. edge_type: Optional[str] The edge type name of the edge.""" pass
Returns weight of the given node names and edge type.
Parameters
- src (str): The node name of the source node.
- dst (str): The node name of the destination node.
- edge_type (Optional[str]): The edge type name of the edge.
View Source
def get_edge_weight_from_node_names(self, src_name: str, dst_name: str) -> float: """Returns weight of the given node names. Parameters ---------- src_name: str The node name of the source node. dst_name: str The node name of the destination node.""" pass
Returns weight of the given node names.
Parameters
- src_name (str): The node name of the source node.
- dst_name (str): The node name of the destination node.
View Source
def get_unchecked_node_name_from_node_id(self, node_id: int) -> str: """Returns result with the node name. Parameters ---------- node_id: int The node ID whose name is to be returned. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass
Returns result with the node name.
Parameters
- node_id (int): The node ID whose name is to be returned.
Safety
If the given node ID does not exist in the current graph the method will raise a panic.
View Source
def get_node_name_from_node_id(self, node_id: int) -> str: """Returns result with the node name. Parameters ---------- node_id: int The node ID whose name is to be returned.""" pass
Returns result with the node name.
Parameters
- node_id (int): The node ID whose name is to be returned.
View Source
def get_node_id_from_node_name(self, node_name: str) -> int: """Returns result with the node ID. Parameters ---------- node_name: str The node name whose node ID is to be returned. Raises ------- ValueError When the given node name does not exists in the current graph.""" pass
Returns result with the node ID.
Parameters
- node_name (str): The node name whose node ID is to be returned.
Raises
- ValueError: When the given node name does not exists in the current graph.
View Source
def get_node_ids_from_node_names(self, node_names: List[str]) -> np.ndarray: """Returns result with the node IDs. Parameters ---------- node_names: List[str] The node names whose node IDs is to be returned. Raises ------- ValueError When any of the given node name does not exists in the current graph.""" pass
Returns result with the node IDs.
Parameters
- node_names (List[str]): The node names whose node IDs is to be returned.
Raises
- ValueError: When any of the given node name does not exists in the current graph.
View Source
def get_edge_node_ids_from_edge_node_names(self, edge_node_names: List[Tuple[str, str]]) -> List[Tuple[int, int]]: """Returns result with the edge node IDs. Parameters ---------- edge_node_names: List[Tuple[str, str]] The node names whose node IDs is to be returned. Raises ------- ValueError When any of the given node name does not exists in the current graph.""" pass
Returns result with the edge node IDs.
Parameters
- edge_node_names (List[Tuple[str, str]]): The node names whose node IDs is to be returned.
Raises
- ValueError: When any of the given node name does not exists in the current graph.
View Source
def get_edge_node_names_from_edge_node_ids(self, edge_node_ids: List[Tuple[int, int]]) -> List[Tuple[str, str]]: """Returns result with the edge node names. Parameters ---------- edge_node_ids: List[Tuple[int, int]] The node names whose node names is to be returned. Raises ------- ValueError When any of the given node IDs does not exists in the current graph.""" pass
Returns result with the edge node names.
Parameters
- edge_node_ids (List[Tuple[int, int]]): The node names whose node names is to be returned.
Raises
- ValueError: When any of the given node IDs does not exists in the current graph.
View Source
def get_node_type_ids_from_node_name(self, node_name: str) -> Optional[List[int]]: """Return node type ID for the given node name if available. Parameters ---------- node_name: str Name of the node.""" pass
Return node type ID for the given node name if available.
Parameters
- node_name (str): Name of the node.
View Source
def get_node_type_name_from_node_name(self, node_name: str) -> Optional[List[str]]: """Return node type name for the given node name if available. Parameters ---------- node_name: str Name of the node.""" pass
Return node type name for the given node name if available.
Parameters
- node_name (str): Name of the node.
View Source
def get_edge_count_from_edge_type_id(self, edge_type_id: Optional[int]) -> int: """Return number of edges with given edge type ID. If None is given as an edge type ID, the unknown edge type IDs will be returned. Parameters ---------- edge_type_id: Optional[int] The edge type ID to count the edges of.""" pass
Return number of edges with given edge type ID.
If None is given as an edge type ID, the unknown edge type IDs will be returned.
Parameters
- edge_type_id (Optional[int]): The edge type ID to count the edges of.
View Source
def get_edge_type_id_from_edge_type_name(self, edge_type_name: Optional[str]) -> Optional[int]: """Return edge type ID curresponding to given edge type name. If None is given as an edge type ID, None is returned. Parameters ---------- edge_type_name: Optional[str] The edge type name whose ID is to be returned.""" pass
Return edge type ID curresponding to given edge type name.
If None is given as an edge type ID, None is returned.
Parameters
- edge_type_name (Optional[str]): The edge type name whose ID is to be returned.
View Source
def get_edge_count_from_edge_type_name(self, edge_type_name: Optional[str]) -> int: """Return number of edges with given edge type name. If None is given as an edge type name, the unknown edge types will be returned. Parameters ---------- edge_type_name: Optional[str] The edge type name to count the edges of.""" pass
Return number of edges with given edge type name.
If None is given as an edge type name, the unknown edge types will be returned.
Parameters
- edge_type_name (Optional[str]): The edge type name to count the edges of.
View Source
def get_node_type_id_from_node_type_name(self, node_type_name: str) -> int: """Return node type ID curresponding to given node type name. If None is given as an node type ID, None is returned. Parameters ---------- node_type_name: str The node type name whose ID is to be returned.""" pass
Return node type ID curresponding to given node type name.
If None is given as an node type ID, None is returned.
Parameters
- node_type_name (str): The node type name whose ID is to be returned.
View Source
def get_node_count_from_node_type_id(self, node_type_id: Optional[int]) -> int: """Return number of nodes with given node type ID. If None is given as an node type ID, the unknown node types will be returned. Parameters ---------- node_type_id: Optional[int] The node type ID to count the nodes of.""" pass
Return number of nodes with given node type ID.
If None is given as an node type ID, the unknown node types will be returned.
Parameters
- node_type_id (Optional[int]): The node type ID to count the nodes of.
View Source
def get_node_count_from_node_type_name(self, node_type_name: Optional[str]) -> int: """Return number of nodes with given node type name. If None is given as an node type name, the unknown node types will be returned. Parameters ---------- node_type_name: Optional[str] The node type name to count the nodes of.""" pass
Return number of nodes with given node type name.
If None is given as an node type name, the unknown node types will be returned.
Parameters
- node_type_name (Optional[str]): The node type name to count the nodes of.
View Source
def get_neighbour_node_ids_from_node_id(self, node_id: int) -> np.ndarray: """Return vector of destinations for the given source node ID. Parameters ---------- node_id: int Node ID whose neighbours are to be retrieved.""" pass
Return vector of destinations for the given source node ID.
Parameters
- node_id (int): Node ID whose neighbours are to be retrieved.
View Source
def get_neighbour_node_ids_from_node_name(self, node_name: str) -> np.ndarray: """Return vector of destinations for the given source node name. Parameters ---------- node_name: str Node ID whose neighbours are to be retrieved.""" pass
Return vector of destinations for the given source node name.
Parameters
- node_name (str): Node ID whose neighbours are to be retrieved.
View Source
def get_neighbour_node_names_from_node_name(self, node_name: str) -> List[str]: """Return vector of destination names for the given source node name. Parameters ---------- node_name: str Node name whose neighbours are to be retrieved.""" pass
Return vector of destination names for the given source node name.
Parameters
- node_name (str): Node name whose neighbours are to be retrieved.
View Source
def get_minmax_edge_ids_from_node_ids(self, src: int, dst: int) -> Tuple[int, int]: """Return range of outbound edges IDs for all the edges bewteen the given source and destination nodes. This operation is meaningfull only in a multigraph. Parameters ---------- src: int Source node. dst: int Destination node.""" pass
Return range of outbound edges IDs for all the edges bewteen the given source and destination nodes. This operation is meaningfull only in a multigraph.
Parameters
- src (int): Source node.
- dst (int): Destination node.
View Source
def get_edge_id_from_node_ids_and_edge_type_id(self, src: int, dst: int, edge_type: Optional[int]) -> int: """Return edge ID for given tuple of nodes and edge type. This method will return an error if the graph does not contain the requested edge with edge type. Parameters ---------- src: int Source node of the edge. dst: int Destination node of the edge. edge_type: Optional[int] Edge Type of the edge.""" pass
Return edge ID for given tuple of nodes and edge type.
This method will return an error if the graph does not contain the requested edge with edge type.
Parameters
- src (int): Source node of the edge.
- dst (int): Destination node of the edge.
- edge_type (Optional[int]): Edge Type of the edge.
View Source
def get_edge_id_from_node_names(self, src_name: str, dst_name: str) -> int: """Return edge ID for given tuple of node names. This method will return an error if the graph does not contain the requested edge with edge type. Parameters ---------- src_name: str Source node name of the edge. dst_name: str Destination node name of the edge.""" pass
Return edge ID for given tuple of node names.
This method will return an error if the graph does not contain the requested edge with edge type.
Parameters
- src_name (str): Source node name of the edge.
- dst_name (str): Destination node name of the edge.
View Source
def get_edge_id_from_node_names_and_edge_type_name(self, src_name: str, dst_name: str, edge_type_name: Optional[str]) -> int: """Return edge ID for given tuple of node names and edge type name. This method will return an error if the graph does not contain the requested edge with edge type. Parameters ---------- src_name: str Source node name of the edge. dst_name: str Destination node name of the edge. edge_type_name: Optional[str] Edge type name.""" pass
Return edge ID for given tuple of node names and edge type name.
This method will return an error if the graph does not contain the requested edge with edge type.
Parameters
- src_name (str): Source node name of the edge.
- dst_name (str): Destination node name of the edge.
- edge_type_name (Optional[str]): Edge type name.
View Source
def get_edge_type_ids_from_edge_type_names(self, edge_type_names: List[Optional[str]]) -> List[Optional[int]]: """Return translated edge types from string to internal edge ID. Parameters ---------- edge_type_names: List[Optional[str]] Vector of edge types to be converted.""" pass
Return translated edge types from string to internal edge ID.
Parameters
- edge_type_names (List[Optional[str]]): Vector of edge types to be converted.
View Source
def get_node_type_ids_from_node_type_names(self, node_type_names: List[Optional[str]]) -> List[Optional[int]]: """Return translated node types from string to internal node ID. Parameters ---------- node_type_names: List[Optional[str]] Vector of node types to be converted.""" pass
Return translated node types from string to internal node ID.
Parameters
- node_type_names (List[Optional[str]]): Vector of node types to be converted.
View Source
def get_multiple_node_type_ids_from_node_type_names(self, node_type_names: List[Optional[List[str]]]) -> List[Optional[List[int]]]: """Return translated node types from string to internal node ID. Parameters ---------- node_type_names: List[Optional[List[str]]] Vector of node types to be converted. Raises ------- ValueError If the graph does not have node types. ValueError If any of the given node type names do not exists in the graph.""" pass
Return translated node types from string to internal node ID.
Parameters
- node_type_names (List[Optional[List[str]]]): Vector of node types to be converted.
Raises
- ValueError: If the graph does not have node types.
- ValueError: If any of the given node type names do not exists in the graph.
View Source
def get_unchecked_minmax_edge_ids_from_source_node_id(self, src: int) -> Tuple[int, int]: """Return range of outbound edges IDs which have as source the given Node. The method will panic if the given source node ID is higher than the number of nodes in the graph. Parameters ---------- src: int Node for which we need to compute the cumulative_node_degrees range. Safety ------ If the given node ID does not exist in the current graph the method will raise a panic.""" pass
Return range of outbound edges IDs which have as source the given Node.
The method will panic if the given source node ID is higher than the number of nodes in the graph.
Parameters
- src (int): Node for which we need to compute the cumulative_node_degrees range.
Safety
If the given node ID does not exist in the current graph the method will raise a panic.
View Source
def get_minmax_edge_ids_from_source_node_id(self, src: int) -> Tuple[int, int]: """Return range of outbound edges IDs which have as source the given Node. Parameters ---------- src: int Node for which we need to compute the cumulative_node_degrees range.""" pass
Return range of outbound edges IDs which have as source the given Node.
Parameters
- src (int): Node for which we need to compute the cumulative_node_degrees range.
View Source
def get_node_type_name_from_node_type_id(self, node_type_id: int) -> str: """Return node type name of given node type. There is no need for a unchecked version since we will have to map on the note_types anyway. Parameters ---------- node_type_id: int Id of the node type.""" pass
Return node type name of given node type.
There is no need for a unchecked version since we will have to map on the note_types anyway.
Parameters
- node_type_id (int): Id of the node type.
View Source
def get_unchecked_node_type_names_from_node_type_ids(self, node_type_ids: List[int]) -> List[str]: """Return node type name of given node type. Parameters ---------- node_type_ids: List[int] Id of the node type. Safety ------ The method will panic if the graph does not contain node types.""" pass
Return node type name of given node type.
Parameters
- node_type_ids (List[int]): Id of the node type.
Safety
The method will panic if the graph does not contain node types.
View Source
def is_unchecked_connected_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is not a singleton nor a singleton with selfloop. Parameters ---------- node_id: int The node to be checked for. Safety ------ If the given node ID does not exists in the graph this method will panic.""" pass
Returns boolean representing if given node is not a singleton nor a singleton with selfloop.
Parameters
- node_id (int): The node to be checked for.
Safety
If the given node ID does not exists in the graph this method will panic.
View Source
def is_unchecked_disconnected_node_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a singleton or a singleton with selfloop. Parameters ---------- node_id: int The node to be checked for. Safety ------ If the given node ID does not exists in the graph this method will panic.""" pass
Returns boolean representing if given node is a singleton or a singleton with selfloop.
Parameters
- node_id (int): The node to be checked for.
Safety
If the given node ID does not exists in the graph this method will panic.
View Source
def is_unchecked_singleton_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a singleton. Parameters ---------- node_id: int The node to be checked for. Safety ------ If the given node ID does not exists in the graph this method will panic.""" pass
Returns boolean representing if given node is a singleton.
Parameters
- node_id (int): The node to be checked for.
Safety
If the given node ID does not exists in the graph this method will panic.
View Source
def is_singleton_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a singleton. Parameters ---------- node_id: int The node to be checked for.""" pass
Returns boolean representing if given node is a singleton.
Parameters
- node_id (int): The node to be checked for.
View Source
def is_unchecked_singleton_with_selfloops_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a singleton with self-loops. Parameters ---------- node_id: int The node to be checked for.""" pass
Returns boolean representing if given node is a singleton with self-loops.
Parameters
- node_id (int): The node to be checked for.
View Source
def is_singleton_with_selfloops_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a singleton with self-loops. Parameters ---------- node_id: int The node to be checked for.""" pass
Returns boolean representing if given node is a singleton with self-loops.
Parameters
- node_id (int): The node to be checked for.
View Source
def is_unchecked_singleton_from_node_name(self, node_name: str) -> bool: """Returns boolean representing if given node is a singleton. Nota that this method will raise a panic if caled with unproper parametrization. Parameters ---------- node_name: str The node name to be checked for. Safety ------ If the given node name does not exist in the graph this method will panic.""" pass
Returns boolean representing if given node is a singleton.
Nota that this method will raise a panic if caled with unproper parametrization.
Parameters
- node_name (str): The node name to be checked for.
Safety
If the given node name does not exist in the graph this method will panic.
View Source
def is_singleton_from_node_name(self, node_name: str) -> bool: """Returns boolean representing if given node is a singleton. Parameters ---------- node_name: str The node name to be checked for.""" pass
Returns boolean representing if given node is a singleton.
Parameters
- node_name (str): The node name to be checked for.
View Source
def has_node_name(self, node_name: str) -> bool: """Returns whether the graph has the given node name. Parameters ---------- node_name: str Name of the node.""" pass
Returns whether the graph has the given node name.
Parameters
- node_name (str): Name of the node.
View Source
def has_node_type_id(self, node_type_id: int) -> bool: """Returns whether the graph has the given node type id. Parameters ---------- node_type_id: int id of the node.""" pass
Returns whether the graph has the given node type id.
Parameters
- node_type_id (int): id of the node.
View Source
def has_node_type_name(self, node_type_name: str) -> bool: """Returns whether the graph has the given node type name. Parameters ---------- node_type_name: str Name of the node.""" pass
Returns whether the graph has the given node type name.
Parameters
- node_type_name (str): Name of the node.
View Source
def has_edge_type_id(self, edge_type_id: int) -> bool: """Returns whether the graph has the given edge type id. Parameters ---------- edge_type_id: int id of the edge.""" pass
Returns whether the graph has the given edge type id.
Parameters
- edge_type_id (int): id of the edge.
View Source
def has_edge_type_name(self, edge_type_name: str) -> bool: """Returns whether the graph has the given edge type name. Parameters ---------- edge_type_name: str Name of the edge.""" pass
Returns whether the graph has the given edge type name.
Parameters
- edge_type_name (str): Name of the edge.
View Source
def has_edge_from_node_ids(self, src: int, dst: int) -> bool: """Returns whether edge passing between given node ids exists. Parameters ---------- src: int Source node id. dst: int Destination node id.""" pass
Returns whether edge passing between given node ids exists.
Parameters
- src (int): Source node id.
- dst (int): Destination node id.
View Source
def has_selfloop_from_node_id(self, node_id: int) -> bool: """Returns whether the given node ID has a selfloop. Parameters ---------- node_id: int Source node id.""" pass
Returns whether the given node ID has a selfloop.
Parameters
- node_id (int): Source node id.
View Source
def has_edge_from_node_ids_and_edge_type_id(self, src: int, dst: int, edge_type: Optional[int]) -> bool: """Returns whether edge with the given type passing between given nodes exists. Parameters ---------- src: int The source node of the edge. dst: int The destination node of the edge. edge_type: Optional[int] The (optional) edge type.""" pass
Returns whether edge with the given type passing between given nodes exists.
Parameters
- src (int): The source node of the edge.
- dst (int): The destination node of the edge.
- edge_type (Optional[int]): The (optional) edge type.
View Source
def is_unchecked_trap_node_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a trap. If the provided node_id is higher than the number of nodes in the graph, the method will panic. Parameters ---------- node_id: int Integer ID of the node, if this is bigger that the number of nodes it will panic. Safety ------ If the given node ID does not exists in the graph this method will panic.""" pass
Returns boolean representing if given node is a trap.
If the provided node_id is higher than the number of nodes in the graph, the method will panic.
Parameters
- node_id (int): Integer ID of the node, if this is bigger that the number of nodes it will panic.
Safety
If the given node ID does not exists in the graph this method will panic.
View Source
def is_trap_node_from_node_id(self, node_id: int) -> bool: """Returns boolean representing if given node is a trap. Parameters ---------- node_id: int Integer ID of the node, if this is bigger that the number of nodes it will panic.""" pass
Returns boolean representing if given node is a trap.
Parameters
- node_id (int): Integer ID of the node, if this is bigger that the number of nodes it will panic.
View Source
def has_node_name_and_node_type_name(self, node_name: str, node_type_name: Optional[List[str]]) -> bool: """Returns whether the given node name and node type name exist in current graph. Parameters ---------- node_name: str The node name. node_type_name: Optional[List[str]] The node types name.""" pass
Returns whether the given node name and node type name exist in current graph.
Parameters
- node_name (str): The node name.
- node_type_name (Optional[List[str]]): The node types name.
View Source
def has_edge_from_node_names(self, src_name: str, dst_name: str) -> bool: """Returns whether if edge passing between given nodes exists. Parameters ---------- src_name: str The source node name of the edge. dst_name: str The destination node name of the edge.""" pass
Returns whether if edge passing between given nodes exists.
Parameters
- src_name (str): The source node name of the edge.
- dst_name (str): The destination node name of the edge.
View Source
def has_edge_from_node_names_and_edge_type_name(self, src_name: str, dst_name: str, edge_type_name: Optional[str]) -> bool: """Returns whether if edge with type passing between given nodes exists. Parameters ---------- src_name: str The source node name of the edge. dst_name: str The destination node name of the edge. edge_type_name: Optional[str] The (optional) edge type name.""" pass
Returns whether if edge with type passing between given nodes exists.
Parameters
- src_name (str): The source node name of the edge.
- dst_name (str): The destination node name of the edge.
- edge_type_name (Optional[str]): The (optional) edge type name.
View Source
@staticmethod def generate_random_connected_graph(random_state: Optional[int], minimum_node_id: Optional[int], minimum_node_sampling: Optional[int], maximum_node_sampling: Optional[int], number_of_nodes: Optional[int], include_selfloops: Optional[bool], node_type: Optional[str], edge_type: Optional[str], weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new random connected graph with given sizes and types. Parameters ---------- random_state: int The random state to use to reproduce the sampling. minimum_node_id: int The minimum node ID for the connected graph. minimum_node_sampling: int The minimum amount of nodes to sample per node. maximum_node_sampling: int The maximum amount of nodes to sample per node. number_of_nodes: Optional[int] Number of nodes in the chain. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. node_type: Optional[str] The node type to use for the chain. By default 'chain'. edge_type: Optional[str] The node type to use for the chain. By default 'chain'. weight: Optional[float] The weight to use for the edges in the chain. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Chain'.""" pass
Creates new random connected graph with given sizes and types.
Parameters
- random_state (int): The random state to use to reproduce the sampling.
- minimum_node_id (int): The minimum node ID for the connected graph.
- minimum_node_sampling (int): The minimum amount of nodes to sample per node.
- maximum_node_sampling (int): The maximum amount of nodes to sample per node.
- number_of_nodes (Optional[int]): Number of nodes in the chain. By default 10.
- include_selfloops (Optional[bool]): Whether to include selfloops.
- node_type (Optional[str]): The node type to use for the chain. By default 'chain'.
- edge_type (Optional[str]): The node type to use for the chain. By default 'chain'.
- weight (Optional[float]): The weight to use for the edges in the chain. By default None.
- directed (Optional[bool]): Whether the graph is to built as directed. By default false.
- name (Optional[str]): Name of the graph. By default 'Chain'.
View Source
@staticmethod def generate_random_spanning_tree(random_state: Optional[int], minimum_node_id: Optional[int], number_of_nodes: Optional[int], include_selfloops: Optional[bool], node_type: Optional[str], edge_type: Optional[str], weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new random connected graph with given sizes and types. Parameters ---------- random_state: int The random state to use to reproduce the sampling. minimum_node_id: int The minimum node ID for the connected graph. minimum_node_sampling: int The minimum amount of nodes to sample per node. maximum_node_sampling: int The maximum amount of nodes to sample per node. number_of_nodes: Optional[int] Number of nodes in the chain. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. node_type: Optional[str] The node type to use for the chain. By default 'chain'. edge_type: Optional[str] The node type to use for the chain. By default 'chain'. weight: Optional[float] The weight to use for the edges in the chain. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Chain'.""" pass
Creates new random connected graph with given sizes and types.
Parameters
- random_state (int): The random state to use to reproduce the sampling.
- minimum_node_id (int): The minimum node ID for the connected graph.
- minimum_node_sampling (int): The minimum amount of nodes to sample per node.
- maximum_node_sampling (int): The maximum amount of nodes to sample per node.
- number_of_nodes (Optional[int]): Number of nodes in the chain. By default 10.
- include_selfloops (Optional[bool]): Whether to include selfloops.
- node_type (Optional[str]): The node type to use for the chain. By default 'chain'.
- edge_type (Optional[str]): The node type to use for the chain. By default 'chain'.
- weight (Optional[float]): The weight to use for the edges in the chain. By default None.
- directed (Optional[bool]): Whether the graph is to built as directed. By default false.
- name (Optional[str]): Name of the graph. By default 'Chain'.
View Source
@staticmethod def generate_circle_graph(minimum_node_id: Optional[int], number_of_nodes: Optional[int], include_selfloops: Optional[bool], node_type: Optional[str], edge_type: Optional[str], weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new circle graph with given sizes and types. Parameters ---------- minimum_node_id: Optional[int] Minimum node ID to start with. May be needed when circleing graphs. By default 0. number_of_nodes: Optional[int] Number of nodes in the circle. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. node_type: Optional[str] The node type to use for the circle. By default 'circle'. edge_type: Optional[str] The node type to use for the circle. By default 'circle'. weight: Optional[float] The weight to use for the edges in the circle. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Circle'.""" pass
Creates new circle graph with given sizes and types.
Parameters
- minimum_node_id (Optional[int]): Minimum node ID to start with. May be needed when circleing graphs. By default 0.
- number_of_nodes (Optional[int]): Number of nodes in the circle. By default 10.
- include_selfloops (Optional[bool]): Whether to include selfloops.
- node_type (Optional[str]): The node type to use for the circle. By default 'circle'.
- edge_type (Optional[str]): The node type to use for the circle. By default 'circle'.
- weight (Optional[float]): The weight to use for the edges in the circle. By default None.
- directed (Optional[bool]): Whether the graph is to built as directed. By default false.
- name (Optional[str]): Name of the graph. By default 'Circle'.
View Source
@staticmethod def generate_chain_graph(minimum_node_id: Optional[int], number_of_nodes: Optional[int], include_selfloops: Optional[bool], node_type: Optional[str], edge_type: Optional[str], weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new chain graph with given sizes and types. Parameters ---------- minimum_node_id: Optional[int] Minimum node ID to start with. May be needed when chaining graphs. By default 0. number_of_nodes: Optional[int] Number of nodes in the chain. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. node_type: Optional[str] The node type to use for the chain. By default 'chain'. edge_type: Optional[str] The node type to use for the chain. By default 'chain'. weight: Optional[float] The weight to use for the edges in the chain. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Chain'.""" pass
Creates new chain graph with given sizes and types.
Parameters
- minimum_node_id (Optional[int]): Minimum node ID to start with. May be needed when chaining graphs. By default 0.
- number_of_nodes (Optional[int]): Number of nodes in the chain. By default 10.
- include_selfloops (Optional[bool]): Whether to include selfloops.
- node_type (Optional[str]): The node type to use for the chain. By default 'chain'.
- edge_type (Optional[str]): The node type to use for the chain. By default 'chain'.
- weight (Optional[float]): The weight to use for the edges in the chain. By default None.
- directed (Optional[bool]): Whether the graph is to built as directed. By default false.
- name (Optional[str]): Name of the graph. By default 'Chain'.
View Source
@staticmethod def generate_complete_graph(minimum_node_id: Optional[int], number_of_nodes: Optional[int], include_selfloops: Optional[bool], node_type: Optional[str], edge_type: Optional[str], weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new complete graph with given sizes and types. Parameters ---------- minimum_node_id: Optional[int] Minimum node ID to start with. May be needed when combining graphs. By default 0. number_of_nodes: Optional[int] Number of nodes in the chain. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. node_type: Optional[str] The node type to use. By default 'complete'. edge_type: Optional[str] The node type to use. By default 'complete'. weight: Optional[float] The weight to use for the edges. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Complete'.""" pass
Creates new complete graph with given sizes and types.
Parameters
- minimum_node_id (Optional[int]): Minimum node ID to start with. May be needed when combining graphs. By default 0.
- number_of_nodes (Optional[int]): Number of nodes in the chain. By default 10.
- include_selfloops (Optional[bool]): Whether to include selfloops.
- node_type (Optional[str]): The node type to use. By default 'complete'.
- edge_type (Optional[str]): The node type to use. By default 'complete'.
- weight (Optional[float]): The weight to use for the edges. By default None.
- directed (Optional[bool]): Whether the graph is to built as directed. By default false.
- name (Optional[str]): Name of the graph. By default 'Complete'.
View Source
@staticmethod def generate_barbell_graph(minimum_node_id: Optional[int], left_clique_nodes_number: Optional[int], right_clique_nodes_number: Optional[int], chain_nodes_number: Optional[int], include_selfloops: Optional[bool], left_clique_node_type: Optional[str], right_clique_node_type: Optional[str], chain_node_type: Optional[str], left_clique_edge_type: Optional[str], right_clique_edge_type: Optional[str], chain_edge_type: Optional[str], left_clique_weight: Optional[float], right_clique_weight: Optional[float], chain_weight: Optional[float], directed: Optional[bool], name: Optional[str]) -> Graph: """Creates new barbell graph with given sizes and types. Parameters ---------- minimum_node_id: Optional[int] Minimum node ID to start with. May be needed when chaining graphs. By default 0. left_clique_nodes_number: Optional[int] Number of nodes in the left clique. By default 10. right_clique_nodes_number: Optional[int] Number of nodes in the right clique. By default equal to the left clique. chain_nodes_number: Optional[int] Number of nodes in the chain. By default 10. include_selfloops: Optional[bool] Whether to include selfloops. left_clique_node_type: Optional[str] The node type to use for the left clique. By default 'left_clique'. right_clique_node_type: Optional[str] The node type to use for the right clique. By default 'right_clique'. chain_node_type: Optional[str] The node type to use for the chain. By default 'chain'. left_clique_edge_type: Optional[str] The node type to use for the left clique. By default 'left_clique'. right_clique_edge_type: Optional[str] The node type to use for the right clique. By default 'right_clique'. chain_edge_type: Optional[str] The node type to use for the chain. By default 'chain'. left_clique_weight: Optional[float] The weight to use for the edges in the left clique. By default None. right_clique_weight: Optional[float] The weight to use for the edges in the right clique. By default None. chain_weight: Optional[float] The weight to use for the edges in the chain. By default None. directed: Optional[bool] Whether the graph is to built as directed. By default false. name: Optional[str] Name of the graph. By default 'Barbell'. Raises ------- ValueError If the edge weights are provided only for a subset.""" pass
Creates new barbell graph with given sizes and types.
Parameters
- minimum_node_id (Optional[int]): Minimum node ID to start with. May be needed when chaining graphs. By default 0.
- left_clique_nodes_number (Optional[int]): Number of nodes in the left clique. By default 10.
- right_clique_nodes_number (Optional[int]): Number of nodes in the right clique. By default equal to the left clique.
- chain_nodes_number (Optional[int]): Number of nodes in the chain. By default 10.
- include_selfloops (Optional[bool]): Whether to include selfloops.
- left_clique_node_type (Optional[str]): The node type to use for the left clique. By default 'left_clique'.
- right_clique_node_type (Optional[str]): The node type to use for the right clique. By default 'right_clique'.
- chain_node_type (Optional[str]): The node type to use for the chain. By default 'chain'.
- left_clique_edge_type (Optional[str]): The node type to use for the left clique. By default 'left_clique'.
- right_clique_edge_type (Optional[str]): The node type to use for the right clique. By default 'right_clique'.
- chain_edge_type (Optional[str]): The node type to use for the chain. By default 'chain'.
- left_clique_weight (Optional[float]): The weight to use for the edges in the left clique. By default None.
- right_clique_weight (Optional[float]): The weight to use for the edges in the right clique. By default None.
- chain_weight (Optional[float]): The weight to use for the edges in the chain. By default None.
- directed (Optional[bool]): Whether the graph is to built as directed. By default false.
- name (Optional[str]): Name of the graph. By default 'Barbell'.
Raises
- ValueError: If the edge weights are provided only for a subset.
View Source
def are_nodes_remappable(self, other: Graph) -> bool: """Return whether nodes are remappable to those of the given graph. Parameters ---------- other: Graph graph towards remap the nodes to.""" pass
Return whether nodes are remappable to those of the given graph.
Parameters
- other (Graph): graph towards remap the nodes to.
View Source
def remap_unchecked_from_node_ids(self, node_ids: List[int]) -> Graph: """Returns graph remapped using given node IDs ordering. Parameters ---------- node_ids: List[int] The node Ids to remap the graph to. Safety ------ This method will cause a panic if the node IDs are either: * Not unique * Not available for each of the node IDs of the graph.""" pass
Returns graph remapped using given node IDs ordering.
Parameters
- node_ids (List[int]): The node Ids to remap the graph to.
Safety
This method will cause a panic if the node IDs are either:
- Not unique
- Not available for each of the node IDs of the graph.
View Source
def remap_from_node_ids(self, node_ids: List[int]) -> Graph: """Returns graph remapped using given node IDs ordering. Parameters ---------- node_ids: List[int] The node Ids to remap the graph to. Raises ------- ValueError If the given node IDs are not unique. ValueError If the given node IDs are not available for all the values in the graph.""" pass
Returns graph remapped using given node IDs ordering.
Parameters
- node_ids (List[int]): The node Ids to remap the graph to.
Raises
- ValueError: If the given node IDs are not unique.
- ValueError: If the given node IDs are not available for all the values in the graph.
View Source
def remap_from_node_names(self, node_names: List[str]) -> Graph: """Returns graph remapped using given node names ordering. Parameters ---------- node_names: List[str] The node names to remap the graph to. Raises ------- ValueError If the given node names are not unique. ValueError If the given node names are not available for all the values in the graph.""" pass
Returns graph remapped using given node names ordering.
Parameters
- node_names (List[str]): The node names to remap the graph to.
Raises
- ValueError: If the given node names are not unique.
- ValueError: If the given node names are not available for all the values in the graph.
View Source
def remap_from_graph(self, other: Graph) -> Graph: """Return graph remapped towards nodes of the given graph. Parameters ---------- other: Graph The graph to remap towards.""" pass
Return graph remapped towards nodes of the given graph.
Parameters
- other (Graph): The graph to remap towards.
View Source
def remove_components(self, node_names: Optional[List[str]], node_types: Optional[List[Optional[str]]], edge_types: Optional[List[Optional[str]]], minimum_component_size: Optional[int], top_k_components: Optional[int], verbose: Optional[bool]) -> Graph: """remove all the components that are not connected to interesting nodes and edges. Parameters ---------- node_names: Optional[List[str]] The name of the nodes of which components to keep. node_types: Optional[List[Optional[str]]] The types of the nodes of which components to keep. edge_types: Optional[List[Optional[str]]] The types of the edges of which components to keep. minimum_component_size: Optional[int] Optional, Minimum size of the components to keep. top_k_components: Optional[int] Optional, number of components to keep sorted by number of nodes. verbose: Optional[bool] Whether to show the loading bar.""" pass
remove all the components that are not connected to interesting nodes and edges.
Parameters
- node_names (Optional[List[str]]): The name of the nodes of which components to keep.
- node_types (Optional[List[Optional[str]]]): The types of the nodes of which components to keep.
- edge_types (Optional[List[Optional[str]]]): The types of the edges of which components to keep.
- minimum_component_size (Optional[int]): Optional, Minimum size of the components to keep.
- top_k_components (Optional[int]): Optional, number of components to keep sorted by number of nodes.
- verbose (Optional[bool]): Whether to show the loading bar.
View Source
def replace(self, node_name_mapping: Optional[Dict[str, str]], node_type_name_mapping: Optional[Dict[str, str]], edge_type_name_mapping: Optional[Dict[str, str]]) -> Graph: """Replace given node, node type and edge type names. Parameters ---------- node_name_mapping: Optional[Dict[str, str]] The node names to replace. node_type_name_mapping: Optional[Dict[str, str]] The node type names to replace. edge_type_name_mapping: Optional[Dict[str, str]] The edge type names to replace. Raises ------- ValueError If the given node names mapping would lead to nodes duplication.""" pass
Replace given node, node type and edge type names.
Parameters
- node_name_mapping (Optional[Dict[str, str]]): The node names to replace.
- node_type_name_mapping (Optional[Dict[str, str]]): The node type names to replace.
- edge_type_name_mapping (Optional[Dict[str, str]]): The edge type names to replace.
Raises
- ValueError: If the given node names mapping would lead to nodes duplication.
View Source
def report(self) -> Dict[str, str]: """Returns report relative to the graph metrics The report includes the following metrics by default: * Name of the graph * Whether the graph is directed or undirected * Number of singleton nodes * Number of nodes - If the graph has nodes, we also compute: * Minimum unweighted node degree * Maximum unweighted node degree * Unweighted node degree mean * Number of edges * Number of self-loops * Number of singleton with self-loops * Whether the graph is a multigraph * Number of parallel edges * Number of directed edges - If the graph has edges, we also compute: * Rate of self-loops * Whether the graph has weighted edges - If the graph has weights, we also compute: * Minimum weighted node degree * Maximum weighted node degree * Weighted node degree mean * The total edge weights * Whether the graph has node types - If the graph has node types, we also compute: * Whether the graph has singleton node types * The number of node types * The number of nodes with unknown node types * The number of nodes with known node types * Whether the graph has edge types - If the graph has edge types, we also compute: * Whether the graph has singleton edge types * The number of edge types * The number of edges with unknown edge types * The number of edges with known edge types On request, since it takes more time to compute it, the method also provides:""" pass
Returns report relative to the graph metrics
The report includes the following metrics by default:
- Name of the graph
- Whether the graph is directed or undirected
- Number of singleton nodes
- Number of nodes
- If the graph has nodes, we also compute:
- Minimum unweighted node degree
- Maximum unweighted node degree
- Unweighted node degree mean
- Number of edges
- Number of self-loops
- Number of singleton with self-loops
- Whether the graph is a multigraph
- Number of parallel edges
- Number of directed edges
- If the graph has edges, we also compute:
- Rate of self-loops
- Whether the graph has weighted edges
- If the graph has weights, we also compute:
- Minimum weighted node degree
- Maximum weighted node degree
- Weighted node degree mean
- The total edge weights
- Whether the graph has node types
- If the graph has node types, we also compute:
- Whether the graph has singleton node types
- The number of node types
- The number of nodes with unknown node types
- The number of nodes with known node types
- Whether the graph has edge types
- If the graph has edge types, we also compute:
- Whether the graph has singleton edge types
- The number of edge types
- The number of edges with unknown edge types
- The number of edges with known edge types
On request, since it takes more time to compute it, the method also provides:
View Source
def overlap_textual_report(self, other: Graph, verbose: Optional[bool]) -> str: """Return rendered textual report about the graph overlaps. Parameters ---------- other: Graph graph to create overlap report with. verbose: Optional[bool] Whether to shor the loading bars.""" pass
Return rendered textual report about the graph overlaps.
Parameters
- other (Graph): graph to create overlap report with.
- verbose (Optional[bool]): Whether to shor the loading bars.
View Source
def get_node_report_from_node_id(self, node_id: int) -> str: """Return human-readable html report of the given node. The report, by default, is rendered using html. Parameters ---------- node_id: int Whether to show a loading bar in graph operations.""" pass
Return human-readable html report of the given node.
The report, by default, is rendered using html.
Parameters
- node_id (int): Whether to show a loading bar in graph operations.
View Source
def get_node_report_from_node_name(self, node_name: str) -> str: """Return human-readable html report of the given node. The report, by default, is rendered using html. Parameters ---------- node_name: str Whether to show a loading bar in graph operations.""" pass
Return human-readable html report of the given node.
The report, by default, is rendered using html.
Parameters
- node_name (str): Whether to show a loading bar in graph operations.
View Source
def textual_report(self) -> str: """Return html short textual report of the graph. TODO! Add reports on triangles TODO! Add reports on connected components TODO! Add reports on various node metrics TODO! Add reports on various edge metrics NOTE! Most of the above TODOs will require first to implement the support for the fast computation of the inbound edges in a directed graphs""" pass
Return html short textual report of the graph.
TODO! Add reports on triangles TODO! Add reports on connected components TODO! Add reports on various node metrics TODO! Add reports on various edge metrics NOTE! Most of the above TODOs will require first to implement the support for the fast computation of the inbound edges in a directed graphs
View Source
def add_selfloops(self, edge_type_name: Optional[str], weight: Optional[float]) -> Graph: """Returns new graph with added in missing self-loops with given edge type and weight. Parameters ---------- Raises ------- ValueError If the edge type for the new selfloops is provided but the graph does not have edge types. ValueError If the edge weight for the new selfloops is provided but the graph does not have edge weights. ValueError If the edge weight for the new selfloops is NOT provided but the graph does have edge weights.""" pass
Returns new graph with added in missing self-loops with given edge type and weight.
Parameters
Raises
- ValueError: If the edge type for the new selfloops is provided but the graph does not have edge types.
- ValueError: If the edge weight for the new selfloops is provided but the graph does not have edge weights.
- ValueError: If the edge weight for the new selfloops is NOT provided but the graph does have edge weights.
View Source
def set_inplace_all_edge_types(self, edge_type: str): """Replace all edge types (if present) and set all the edge to edge_type. This happens INPLACE, that is edits the current graph instance. Parameters ---------- edge_type: str The edge type to assing to all the edges. Raises ------- ValueError If the graph does not have edges. ValueError If the graph is a multigraph.""" pass
Replace all edge types (if present) and set all the edge to edge_type.
This happens INPLACE, that is edits the current graph instance.
Parameters
- edge_type (str): The edge type to assing to all the edges.
Raises
- ValueError: If the graph does not have edges.
- ValueError: If the graph is a multigraph.
View Source
def set_all_edge_types(self, edge_type: str) -> Graph: """Replace all edge types (if present) and set all the edge to edge_type. This DOES NOT happen inplace, but created a new instance of the graph. Parameters ---------- edge_type: str The edge type to assing to all the edges.""" pass
Replace all edge types (if present) and set all the edge to edge_type.
This DOES NOT happen inplace, but created a new instance of the graph.
Parameters
- edge_type (str): The edge type to assing to all the edges.
View Source
def set_inplace_all_node_types(self, node_type: str): """Replace all node types (if present) and set all the node to node_type. Parameters ---------- node_type: str The node type to assing to all the nodes.""" pass
Replace all node types (if present) and set all the node to node_type.
Parameters
- node_type (str): The node type to assing to all the nodes.
View Source
def set_all_node_types(self, node_type: str) -> Graph: """Replace all node types (if present) and set all the node to node_type. This DOES NOT happen inplace, but created a new instance of the graph. Parameters ---------- node_type: str The node type to assing to all the nodes.""" pass
Replace all node types (if present) and set all the node to node_type.
This DOES NOT happen inplace, but created a new instance of the graph.
Parameters
- node_type (str): The node type to assing to all the nodes.
View Source
def remove_inplace_node_type_ids(self, node_type_ids_to_remove: List[int]): """Remove given node type ID from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification happens inplace. Parameters ---------- node_type_id_to_remove: int The node type ID to remove. Raises ------- ValueError If the graph does not have node types. ValueError If the given node type ID does not exists in the graph.""" pass
Remove given node type ID from all nodes.
If any given node remains with no node type, that node is labeled with node type None. Note that the modification happens inplace.
Parameters
- node_type_id_to_remove (int): The node type ID to remove.
Raises
- ValueError: If the graph does not have node types.
- ValueError: If the given node type ID does not exists in the graph.
View Source
def remove_inplace_singleton_node_types(self): """Remove singleton node types from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification happens inplace. Raises ------- ValueError If the graph does not have node types.""" pass
Remove singleton node types from all nodes.
If any given node remains with no node type, that node is labeled with node type None. Note that the modification happens inplace.
Raises
- ValueError: If the graph does not have node types.
View Source
def remove_inplace_edge_type_ids(self, edge_type_ids_to_remove: List[int]): """Remove given edge type ID from all edges. Parameters ---------- edge_type_id: int The edge type ID to remove. Raises ------- ValueError If the graph is a multigraph. ValueError If the graph does not have edge types. ValueError If the given edge type ID does not exists in the graph.""" pass
Remove given edge type ID from all edges.
Parameters
- edge_type_id (int): The edge type ID to remove.
Raises
- ValueError: If the graph is a multigraph.
- ValueError: If the graph does not have edge types.
- ValueError: If the given edge type ID does not exists in the graph.
View Source
def remove_inplace_singleton_edge_types(self): """Remove singleton edge types from all edges. If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification happens inplace. Raises ------- ValueError If the graph does not have edge types.""" pass
Remove singleton edge types from all edges.
If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification happens inplace.
Raises
- ValueError: If the graph does not have edge types.
View Source
def remove_inplace_node_type_name(self, node_type_name: str): """Remove given node type name from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification happens inplace. Parameters ---------- node_type_name: str The node type ID to remove. Raises ------- ValueError If the graph does not have node types. ValueError If the given node type name does not exists in the graph.""" pass
Remove given node type name from all nodes.
If any given node remains with no node type, that node is labeled with node type None. Note that the modification happens inplace.
Parameters
- node_type_name (str): The node type ID to remove.
Raises
- ValueError: If the graph does not have node types.
- ValueError: If the given node type name does not exists in the graph.
View Source
def remove_node_type_id(self, node_type_id: int) -> Graph: """Remove given node type ID from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification DOES NOT happen inplace. Parameters ---------- node_type_id: int The node type ID to remove. Raises ------- ValueError If the graph does not have node types. ValueError If the given node type ID does not exists in the graph.""" pass
Remove given node type ID from all nodes.
If any given node remains with no node type, that node is labeled with node type None. Note that the modification DOES NOT happen inplace.
Parameters
- node_type_id (int): The node type ID to remove.
Raises
- ValueError: If the graph does not have node types.
- ValueError: If the given node type ID does not exists in the graph.
View Source
def remove_singleton_node_types(self) -> Graph: """Remove singleton node types from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification DOES NOT happen inplace. Raises ------- ValueError If the graph does not have node types.""" pass
Remove singleton node types from all nodes.
If any given node remains with no node type, that node is labeled with node type None. Note that the modification DOES NOT happen inplace.
Raises
- ValueError: If the graph does not have node types.
View Source
def remove_node_type_name(self, node_type_name: str) -> Graph: """Remove given node type name from all nodes. If any given node remains with no node type, that node is labeled with node type None. Note that the modification DOES NOT happen inplace. Parameters ---------- node_type_name: str The node type ID to remove. Raises ------- ValueError If the graph does not have node types. ValueError If the given node type name does not exists in the graph.""" pass
Remove given node type name from all nodes.
If any given node remains with no node type, that node is labeled with node type None. Note that the modification DOES NOT happen inplace.
Parameters
- node_type_name (str): The node type ID to remove.
Raises
- ValueError: If the graph does not have node types.
- ValueError: If the given node type name does not exists in the graph.
View Source
def remove_inplace_edge_type_name(self, edge_type_name: str): """Remove given edge type name from all edges. If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification happens inplace. Parameters ---------- edge_type_name: str The edge type ID to remove. Raises ------- ValueError If the graph does not have edge types. ValueError If the given edge type name does not exists in the graph.""" pass
Remove given edge type name from all edges.
If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification happens inplace.
Parameters
- edge_type_name (str): The edge type ID to remove.
Raises
- ValueError: If the graph does not have edge types.
- ValueError: If the given edge type name does not exists in the graph.
View Source
def remove_edge_type_id(self, edge_type_id: int) -> Graph: """Remove given edge type ID from all edges. If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification DOES NOT happen inplace. Parameters ---------- edge_type_id: int The edge type ID to remove. Raises ------- ValueError If the graph does not have edge types. ValueError If the given edge type ID does not exists in the graph.""" pass
Remove given edge type ID from all edges.
If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification DOES NOT happen inplace.
Parameters
- edge_type_id (int): The edge type ID to remove.
Raises
- ValueError: If the graph does not have edge types.
- ValueError: If the given edge type ID does not exists in the graph.
View Source
def remove_singleton_edge_types(self) -> Graph: """Remove singleton edge types from all edges. If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification DOES NOT happen inplace. Raises ------- ValueError If the graph does not have edge types.""" pass
Remove singleton edge types from all edges.
If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification DOES NOT happen inplace.
Raises
- ValueError: If the graph does not have edge types.
View Source
def remove_edge_type_name(self, edge_type_name: str) -> Graph: """Remove given edge type name from all edges. If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification DOES NOT happen inplace. Parameters ---------- edge_type_name: str The edge type ID to remove. Raises ------- ValueError If the graph does not have edge types. ValueError If the given edge type name does not exists in the graph.""" pass
Remove given edge type name from all edges.
If any given edge remains with no edge type, that edge is labeled with edge type None. Note that the modification DOES NOT happen inplace.
Parameters
- edge_type_name (str): The edge type ID to remove.
Raises
- ValueError: If the graph does not have edge types.
- ValueError: If the given edge type name does not exists in the graph.
View Source
def remove_inplace_node_types(self): """Remove node types from the graph. Note that the modification happens inplace. Raises ------- ValueError If the graph does not have node types.""" pass
Remove node types from the graph.
Note that the modification happens inplace.
Raises
- ValueError: If the graph does not have node types.
View Source
def remove_node_types(self) -> Graph: """Remove node types from the graph. Note that the modification does not happen inplace. Raises ------- ValueError If the graph does not have node types.""" pass
Remove node types from the graph.
Note that the modification does not happen inplace.
Raises
- ValueError: If the graph does not have node types.
View Source
def remove_inplace_edge_types(self): """Remove edge types from the graph. Note that the modification happens inplace. Raises ------- ValueError If the graph does not have edge types. ValueError If the graph is a multigraph.""" pass
Remove edge types from the graph.
Note that the modification happens inplace.
Raises
- ValueError: If the graph does not have edge types.
- ValueError: If the graph is a multigraph.
View Source
def remove_edge_types(self) -> Graph: """Remove edge types from the graph. Note that the modification does not happen inplace. Raises ------- ValueError If the graph does not have edge types.""" pass
Remove edge types from the graph.
Note that the modification does not happen inplace.
Raises
- ValueError: If the graph does not have edge types.
View Source
def remove_inplace_edge_weights(self): """Remove edge weights from the graph. Note that the modification happens inplace. Raises ------- ValueError If the graph does not have edge weights.""" pass
Remove edge weights from the graph.
Note that the modification happens inplace.
Raises
- ValueError: If the graph does not have edge weights.
View Source
def remove_edge_weights(self) -> Graph: """Remove edge weights from the graph. Note that the modification does not happen inplace. Raises ------- ValueError If the graph does not have edge weights.""" pass
Remove edge weights from the graph.
Note that the modification does not happen inplace.
Raises
- ValueError: If the graph does not have edge weights.
View Source
def sort_by_increasing_outbound_node_degree(self) -> Graph: """Returns graph with node IDs sorted by increasing outbound node degree""" pass
Returns graph with node IDs sorted by increasing outbound node degree
View Source
def sort_by_decreasing_outbound_node_degree(self) -> Graph: """Returns graph with node IDs sorted by decreasing outbound node degree""" pass
Returns graph with node IDs sorted by decreasing outbound node degree
View Source
def sort_by_node_lexicographic_order(self) -> Graph: """Returns graph with node IDs sorted by lexicographic order""" pass
Returns graph with node IDs sorted by lexicographic order
View Source
def get_bfs_topological_sorting_from_node_id(self, root_node_id: int) -> np.ndarray: """Returns topological sorting map using breadth-first search from the given node. Parameters ---------- root_node_id: int Node ID of node to be used as root of BFS Raises ------- ValueError If the given root node ID does not exist in the graph""" pass
Returns topological sorting map using breadth-first search from the given node.
Parameters
- root_node_id (int): Node ID of node to be used as root of BFS
Raises
- ValueError: If the given root node ID does not exist in the graph
View Source
def get_reversed_bfs_topological_sorting_from_node_id(self, root_node_id: int) -> np.ndarray: """Returns topological sorting reversed map using breadth-first search from the given node. Parameters ---------- root_node_id: int Node ID of node to be used as root of BFS Raises ------- ValueError If the given root node ID does not exist in the graph""" pass
Returns topological sorting reversed map using breadth-first search from the given node.
Parameters
- root_node_id (int): Node ID of node to be used as root of BFS
Raises
- ValueError: If the given root node ID does not exist in the graph
View Source
def sort_by_bfs_topological_sorting_from_node_id(self, root_node_id: int) -> Graph: """Returns graph with node IDs sorted using a BFS Parameters ---------- root_node_id: int Node ID of node to be used as root of BFS Raises ------- ValueError If the given root node ID does not exist in the graph""" pass
Returns graph with node IDs sorted using a BFS
Parameters
- root_node_id (int): Node ID of node to be used as root of BFS
Raises
- ValueError: If the given root node ID does not exist in the graph
View Source
def get_sparse_edge_weighting_methods(self) -> List[str]: """Return list of the supported sparse edge weighting methods""" pass
Return list of the supported sparse edge weighting methods
View Source
def get_edge_weighting_methods(self) -> List[str]: """Return list of the supported edge weighting methods""" pass
Return list of the supported edge weighting methods
View Source
def strongly_connected_components(self) -> List[Set[int]]: """Returns list of nodes of the various strongly connected components. This is an implementation of Tarjan algorithm.""" pass
Returns list of nodes of the various strongly connected components.
This is an implementation of Tarjan algorithm.
View Source
def generate_new_edges_from_node_features(self, features: List[List[float]], neighbours_number: Optional[int], max_degree: Optional[int], distance_name: Optional[str], verbose: Optional[bool]) -> Graph: """Returns graph with edges added extracted from given node_features. This operation might distrupt the graph topology. Proceed with caution! Parameters ---------- features: List[List[float]] node_features to use to identify the new neighbours. neighbours_number: Optional[int] Number of neighbours to add. max_degree: Optional[int] The maximum degree a node can have its neighbours augmented. By default 0, that is, only singletons are augmented. distance_name: Optional[str] Name of distance to use. Can either be L2 or COSINE. By default COSINE. verbose: Optional[bool] Whether to show loading bars. Raises ------- ValueError If the graph does not have nodes. ValueError If the given node_features are not provided exactly for each node. ValueError If the node_features do not have a consistent shape. ValueError If the provided number of neighbours is zero.""" pass
Returns graph with edges added extracted from given node_features.
This operation might distrupt the graph topology. Proceed with caution!
Parameters
- features (List[List[float]]): node_features to use to identify the new neighbours.
- neighbours_number (Optional[int]): Number of neighbours to add.
- max_degree (Optional[int]): The maximum degree a node can have its neighbours augmented. By default 0, that is, only singletons are augmented.
- distance_name (Optional[str]): Name of distance to use. Can either be L2 or COSINE. By default COSINE.
- verbose (Optional[bool]): Whether to show loading bars.
Raises
- ValueError: If the graph does not have nodes.
- ValueError: If the given node_features are not provided exactly for each node.
- ValueError: If the node_features do not have a consistent shape.
- ValueError: If the provided number of neighbours is zero.
View Source
def to_directed_inplace(self): """Convert inplace the graph to directed.""" pass
Convert inplace the graph to directed.
View Source
def to_directed(self) -> Graph: """Return a new instance of the current graph as directed""" pass
Return a new instance of the current graph as directed
View Source
def to_upper_triangular(self) -> Graph: """Return the directed graph from the upper triangular adjacency matrix.""" pass
Return the directed graph from the upper triangular adjacency matrix.
View Source
def to_lower_triangular(self) -> Graph: """Return the directed graph from the lower triangular adjacency matrix.""" pass
Return the directed graph from the lower triangular adjacency matrix.
View Source
def to_main_diagonal(self) -> Graph: """Return the graph from the main diagonal adjacency matrix.""" pass
Return the graph from the main diagonal adjacency matrix.
View Source
def to_anti_diagonal(self) -> Graph: """Return the graph from the anti-diagonal adjacency matrix.""" pass
Return the graph from the anti-diagonal adjacency matrix.
View Source
def to_bidiagonal(self) -> Graph: """Return the graph from the bidiagonal adjacency matrix.""" pass
Return the graph from the bidiagonal adjacency matrix.
View Source
def to_arrowhead(self) -> Graph: """Return the graph from the arrowhead adjacency matrix.""" pass
Return the graph from the arrowhead adjacency matrix.
View Source
def to_transposed(self) -> Graph: """Return the graph from the transposed adjacency matrix.""" pass
Return the graph from the transposed adjacency matrix.
View Source
def to_complementary(self) -> Graph: """Return the complementary graph.""" pass
Return the complementary graph.
View Source
def get_transitive_closure(self, iterations: Optional[int], verbose: Optional[bool]) -> Graph: """Returns graph to the i-th transitivity closure iteration. Parameters ---------- iterations: Optional[int] The number of iterations of the transitive closure to execute. If None, the complete transitive closure is computed. verbose: Optional[bool] Whether to show a loading bar while building the graph.""" pass
Returns graph to the i-th transitivity closure iteration.
Parameters
- iterations (Optional[int]): The number of iterations of the transitive closure to execute. If None, the complete transitive closure is computed.
- verbose (Optional[bool]): Whether to show a loading bar while building the graph.
View Source
def get_all_shortest_paths(self, iterations: Optional[int], verbose: Optional[bool]) -> Graph: """Returns graph with unweighted shortest paths computed up to the given depth. The returned graph will have no selfloops. Parameters ---------- iterations: Optional[int] The number of iterations of the transitive closure to execute. If None, the complete transitive closure is computed. verbose: Optional[bool] Whether to show a loading bar while building the graph.""" pass
Returns graph with unweighted shortest paths computed up to the given depth.
The returned graph will have no selfloops.
Parameters
- iterations (Optional[int]): The number of iterations of the transitive closure to execute. If None, the complete transitive closure is computed.
- verbose (Optional[bool]): Whether to show a loading bar while building the graph.
View Source
def get_weighted_all_shortest_paths(self, iterations: Optional[int], use_edge_weights_as_probabilities: Optional[bool], verbose: Optional[bool]) -> Graph: """Returns graph with weighted shortest paths computed up to the given depth. The returned graph will have no selfloops. Parameters ---------- iterations: Optional[int] The number of iterations of the transitive closure to execute. If None, the complete transitive closure is computed. use_edge_weights_as_probabilities: Optional[bool] Whether to treat the edge weights as probabilities. verbose: Optional[bool] Whether to show a loading bar while building the graph. Raises ------- ValueError If the graph does not have weights. ValueError If the graph contains negative weights. ValueError If the user has asked for the weights to be treated as probabilities but the weights are not between 0 and 1.""" pass
Returns graph with weighted shortest paths computed up to the given depth.
The returned graph will have no selfloops.
Parameters
- iterations (Optional[int]): The number of iterations of the transitive closure to execute. If None, the complete transitive closure is computed.
- use_edge_weights_as_probabilities (Optional[bool]): Whether to treat the edge weights as probabilities.
- verbose (Optional[bool]): Whether to show a loading bar while building the graph.
Raises
- ValueError: If the graph does not have weights.
- ValueError: If the graph contains negative weights.
- ValueError: If the user has asked for the weights to be treated as probabilities but the weights are not between 0 and 1.
View Source
def random_spanning_arborescence_kruskal(self, random_state: Optional[int], undesired_edge_types: Optional[Set[Optional[int]]], verbose: Optional[bool]) -> Tuple[Set[Tuple[int, int]], List[int], int, int, int]: """Returns set of edges composing a spanning tree and connected components. The spanning tree is NOT minimal. The given random_state is NOT the root of the tree. This method, additionally, allows for undesired edge types to be used to build the spanning tree only in extremis when it is utterly necessary in order to complete the spanning arborescence. The quintuple returned contains: - Set of the edges used in order to build the spanning arborescence. - Vector of the connected component of each node. - Number of connected components. - Minimum component size. - Maximum component size. Parameters ---------- random_state: Optional[int] The random_state to use for the holdout, undesired_edge_types: Optional[Set[Optional[int]]] Which edge types id to try to avoid. verbose: Optional[bool] Whether to show a loading bar or not.""" pass
Returns set of edges composing a spanning tree and connected components.
The spanning tree is NOT minimal. The given random_state is NOT the root of the tree.
This method, additionally, allows for undesired edge types to be used to build the spanning tree only in extremis when it is utterly necessary in order to complete the spanning arborescence.
The quintuple returned contains:
- Set of the edges used in order to build the spanning arborescence.
- Vector of the connected component of each node.
- Number of connected components.
- Minimum component size.
- Maximum component size.
Parameters
- random_state (Optional[int]): The random_state to use for the holdout,
- undesired_edge_types (Optional[Set[Optional[int]]]): Which edge types id to try to avoid.
- verbose (Optional[bool]): Whether to show a loading bar or not.
View Source
def spanning_arborescence_kruskal(self, verbose: Optional[bool]) -> Tuple[Set[Tuple[int, int]], List[int], int, int, int]: """Returns consistent spanning arborescence using Kruskal. The spanning tree is NOT minimal. The quintuple returned contains: - Set of the edges used in order to build the spanning arborescence. - Vector of the connected component of each node. - Number of connected components. - Minimum component size. - Maximum component size. Parameters ---------- verbose: Optional[bool] Whether to show a loading bar or not.""" pass
Returns consistent spanning arborescence using Kruskal.
The spanning tree is NOT minimal.
The quintuple returned contains:
- Set of the edges used in order to build the spanning arborescence.
- Vector of the connected component of each node.
- Number of connected components.
- Minimum component size.
- Maximum component size.
Parameters
- verbose (Optional[bool]): Whether to show a loading bar or not.
View Source
def connected_components(self, verbose: Optional[bool]) -> Tuple[List[int], int, int, int]: """Compute the connected components building in parallel a spanning tree using [bader's algorithm](https://www.sciencedirect.com/science/article/abs/pii/S0743731505000882). **This works only for undirected graphs.** This method is **not thread save and not deterministic** but by design of the algorithm this shouldn't matter but if we will encounter non-detemristic bugs here is where we want to look. The returned quadruple contains: - Vector of the connected component for each node. - Number of connected components. - Minimum connected component size. - Maximum connected component size. Parameters ---------- verbose: Optional[bool] Whether to show a loading bar or not. Raises ------- ValueError If the given graph is directed. ValueError If the system configuration does not allow for the creation of the thread pool.""" pass
Compute the connected components building in parallel a spanning tree using bader's algorithm.
This works only for undirected graphs.
This method is not thread save and not deterministic but by design of the algorithm this shouldn't matter but if we will encounter non-detemristic bugs here is where we want to look.
The returned quadruple contains:
- Vector of the connected component for each node.
- Number of connected components.
- Minimum connected component size.
- Maximum connected component size.
Parameters
- verbose (Optional[bool]): Whether to show a loading bar or not.
Raises
- ValueError: If the given graph is directed.
- ValueError: If the system configuration does not allow for the creation of the thread pool.
View Source
def approximated_vertex_cover_set(self) -> Set[int]: """Returns 2-approximated verted cover set using greedy algorithm.""" pass
Returns 2-approximated verted cover set using greedy algorithm.
View Source
def to_dot(self) -> str: """Print the current graph in a format compatible with Graphviz dot's format""" pass
Print the current graph in a format compatible with Graphviz dot's format
View Source
def cooccurence_matrix(self, walk_length: int, **kwargs) -> Tuple[np.ndarray, np.ndarray, np.ndarray]: """Return cooccurence matrix-based triples of words, contexts and frequencies. Parameters --------------------- walk_length: int Maximal length of the random walk. On graphs without traps, all walks have this length. window_size: int = 4 Size of the window for local contexts. iterations: int = 1 Number of cycles on the graphs to execute. return_weight: float = 1.0 Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper. explore_weight: float = 1.0 Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper. change_node_type_weight: float = 1.0 Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact. change_edge_type_weight: float = 1.0 Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact. dense_node_mapping: Dict[int, int] = None Mapping to use for converting sparse walk space into a dense space. This object can be created using the method available from graph called `get_dense_node_mapping` that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. max_neighbours: int = None Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk. random_state: int = 42 random_state to use to reproduce the walks. verbose: int = True whether to show or not the loading bar of the walks. Returns ---------------------------- Triple with integer vectors of words and contexts and max-min normalized frequencies.""" pass
Return cooccurence matrix-based triples of words, contexts and frequencies.
Parameters
- walk_length (int): Maximal length of the random walk. On graphs without traps, all walks have this length.
- window_size (int = 4): Size of the window for local contexts.
- iterations (int = 1): Number of cycles on the graphs to execute.
- return_weight (float = 1.0): Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper.
- explore_weight (float = 1.0): Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper.
- change_node_type_weight (float = 1.0): Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact.
- change_edge_type_weight (float = 1.0): Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact.
- dense_node_mapping (Dict[int, int] = None):
Mapping to use for converting sparse walk space into a dense space.
This object can be created using the method available from graph
called
get_dense_node_mapping
that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. - max_neighbours (int = None): Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk.
- random_state (int = 42): random_state to use to reproduce the walks.
- verbose (int = True): whether to show or not the loading bar of the walks.
Returns
- Triple with integer vectors of words and contexts and max-min normalized frequencies.
View Source
def node2vec(self, batch_size: int, walk_length: int, window_size: int, **kwargs) -> Tuple[np.ndarray, np.ndarray]: """Return training batches for Node2Vec models. The batch is composed of a tuple as the following: - (Contexts indices, central nodes indices): the tuple of nodes This does not provide any output value as the model uses NCE loss and basically the central nodes that are fed as inputs work as the outputs value. Parameters --------------------- batch_size: int Number of walks to include within this batch. In some pathological cases, this might leed to an empty batch. These cases include graphs with particularly high number of traps. Consider using the method graph.report() to verify if this might apply to your use case. walk_length: int Maximal length of the random walk. On graphs without traps, all walks have this length. window_size: int Size of the window for local contexts. iterations: int = 1 Number of iterations for each node. return_weight: float = 1.0 Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper. explore_weight: float = 1.0 Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper. change_node_type_weight: float = 1.0 Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact. change_edge_type_weight: float = 1.0 Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact. dense_node_mapping: Dict[int, int] Mapping to use for converting sparse walk space into a dense space. This object can be created using the method available from graph called `get_dense_node_mapping` that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. max_neighbours: int = None Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk. random_state: int random_state to use to reproduce the walks. Returns ---------------------------- Tuple with vector of integer with contexts and words.""" pass
Return training batches for Node2Vec models.
The batch is composed of a tuple as the following:
- (Contexts indices, central nodes indices): the tuple of nodes
This does not provide any output value as the model uses NCE loss and basically the central nodes that are fed as inputs work as the outputs value.
Parameters
- batch_size (int): Number of walks to include within this batch. In some pathological cases, this might leed to an empty batch. These cases include graphs with particularly high number of traps. Consider using the method graph.report() to verify if this might apply to your use case.
- walk_length (int): Maximal length of the random walk. On graphs without traps, all walks have this length.
- window_size (int): Size of the window for local contexts.
- iterations (int = 1): Number of iterations for each node.
- return_weight (float = 1.0): Weight on the probability of returning to node coming from Having this higher tends the walks to be more like a Breadth-First Search. Having this very high (> 2) makes search very local. Equal to the inverse of p in the Node2Vec paper.
- explore_weight (float = 1.0): Weight on the probability of visiting a neighbor node to the one we're coming from in the random walk Having this higher tends the walks to be more like a Depth-First Search. Having this very high makes search more outward. Having this very low makes search very local. Equal to the inverse of q in the Node2Vec paper.
- change_node_type_weight (float = 1.0): Weight on the probability of visiting a neighbor node of a different type than the previous node. This only applies to colored graphs, otherwise it has no impact.
- change_edge_type_weight (float = 1.0): Weight on the probability of visiting a neighbor edge of a different type than the previous edge. This only applies to multigraphs, otherwise it has no impact.
- dense_node_mapping (Dict[int, int]):
Mapping to use for converting sparse walk space into a dense space.
This object can be created using the method available from graph
called
get_dense_node_mapping
that returns a mapping from the non trap nodes (those from where a walk could start) and maps these nodes into a dense range of values. - max_neighbours (int = None): Maximum number of randomly sampled neighbours to consider. If this parameter is used, the walks becomes probabilistic in nature and becomes an approximation of an exact walk.
- random_state (int): random_state to use to reproduce the walks.
Returns
- Tuple with vector of integer with contexts and words.
View Source
def get_node_label_prediction_mini_batch(self, idx: int, batch_size: Optional[int], include_central_node: Optional[bool], return_edge_weights: Optional[bool], max_neighbours: Optional[int]) -> Tuple[Tuple[List[List[int]], Optional[List[List[float]]]], np.ndarray, ]: """Return iterator over neighbours for the given node Parameters ----------------------------- `idx`: int - Seed for the batch. `batch_size`: Optional[int] = 1024 - The dimension of the batch. `include_central_node`: Optional[bool] - Whether to include the central node. `return_edge_weights`: Optional[bool] - Whether to return the edge weights. `max_neighbours`: Optional[int] - Maximal number of neighbours to sample. Returns ----------------------------- Tuple with input nodes, optionally edge weights and one-hot encoded node types.""" pass
Return iterator over neighbours for the given node
Parameters
idx
(int - Seed for the batch.):batch_size
(Optional[int] = 1024 - The dimension of the batch.):include_central_node
(Optional[bool] - Whether to include the central node.):return_edge_weights
(Optional[bool] - Whether to return the edge weights.):max_neighbours
(Optional[int] - Maximal number of neighbours to sample.):
Returns
- Tuple with input nodes, optionally edge weights and one-hot encoded node types.
View Source
def get_edge_prediction_mini_batch(self, idx: int, batch_size: Optional[int], negative_samples_rate: Optional[float], return_node_types: Optional[bool], return_edge_types: Optional[bool], return_edge_metrics: Optional[bool], avoid_false_negatives: Optional[bool], maximal_sampling_attempts: Optional[int], shuffle: Optional[bool], graph_to_avoid: Optional[Graph]) -> Tuple[np.ndarray, Optional[np.ndarray], np.ndarray, Optional[np.ndarray], Optional[np.ndarray], Optional[np.ndarray], np.ndarray, ]: """Returns n-ple with index to build numpy array, source node, source node type, destination node, destination node type, edge type and whether this edge is real or artificial. Parameters ------------- idx: int The index of the batch to generate, behaves like a random random_state, batch_size: Optional[int] The maximal size of the batch to generate, negative_samples: Optional[float] The component of netagetive samples to use. return_node_types: Optional[bool] Whether to return the source and destination nodes node types. return_edge_types: Optional[bool] Whether to return the edge types. The negative edges edge type will be samples at random. return_edge_metrics: Optional[bool] Whether to return the edge metrics. avoid_false_negatives: Optional[bool] Whether to remove the false negatives when generated. It should be left to false, as it has very limited impact on the training, but enabling this will slow things down. maximal_sampling_attempts: Optional[int] Number of attempts to execute to sample the negative edges. shuffle: Optional[bool] Whether to shuffle the samples within the batch. graph_to_avoid: Optional[Graph] The graph whose edges are to be avoided during the generation of false negatives, Raises --------- ValueError If the given amount of negative samples is not a positive finite real value. ValueError If node types are requested but the graph does not contain any. ValueError If node types are requested but the graph contains unknown node types. ValueError If edge types are requested but the graph does not contain any. ValueError If edge types are requested but the graph contains unknown edge types.""" pass
Returns n-ple with index to build numpy array, source node, source node type, destination node, destination node type, edge type and whether this edge is real or artificial.
Parameters
- idx (int): The index of the batch to generate, behaves like a random random_state,
- batch_size (Optional[int]): The maximal size of the batch to generate,
- negative_samples (Optional[float]): The component of netagetive samples to use.
- return_node_types (Optional[bool]): Whether to return the source and destination nodes node types.
- return_edge_types (Optional[bool]): Whether to return the edge types. The negative edges edge type will be samples at random.
- return_edge_metrics (Optional[bool]): Whether to return the edge metrics.
- avoid_false_negatives (Optional[bool]): Whether to remove the false negatives when generated. It should be left to false, as it has very limited impact on the training, but enabling this will slow things down.
- maximal_sampling_attempts (Optional[int]): Number of attempts to execute to sample the negative edges.
- shuffle (Optional[bool]): Whether to shuffle the samples within the batch.
- graph_to_avoid (Optional[Graph]): The graph whose edges are to be avoided during the generation of false negatives,
Raises
- ValueError: If the given amount of negative samples is not a positive finite real value.
- ValueError: If node types are requested but the graph does not contain any.
- ValueError: If node types are requested but the graph contains unknown node types.
- ValueError: If edge types are requested but the graph does not contain any.
- ValueError: If edge types are requested but the graph contains unknown edge types.
View Source
def get_unchecked_edge_prediction_metrics(self, source_node_ids: List[int], destination_node_ids: List[int], normalize: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Returns all available edge prediction metrics for given edges. The metrics returned are, in order: - Adamic Adar index - Jaccard Coefficient - Resource Allocation index - Normalized preferential attachment score Parameters ---------- source_node_ids: List[int] List of source node IDs. destination_node_ids: List[int] List of destination node IDs. normalize: Optional[bool] = True Whether to normalize the metrics. verbose: Optional[bool] = True Whether to show a loading bar. Returns ------- 2D numpy array with metrics.""" pass
Returns all available edge prediction metrics for given edges.
The metrics returned are, in order:
- Adamic Adar index
- Jaccard Coefficient
- Resource Allocation index
- Normalized preferential attachment score
Parameters
- source_node_ids (List[int]): List of source node IDs.
- destination_node_ids (List[int]): List of destination node IDs.
- normalize (Optional[bool] = True): Whether to normalize the metrics.
- verbose (Optional[bool] = True): Whether to show a loading bar.
Returns
- 2D numpy array with metrics.
View Source
def get_edge_prediction_metrics(self, normalize: Optional[bool], verbose: Optional[bool]) -> np.ndarray: """Returns all available edge prediction metrics for given edges. The metrics returned are, in order: - Adamic Adar index - Jaccard Coefficient - Resource Allocation index - Normalized preferential attachment score Parameters ---------- normalize: Optional[bool] = True Whether to normalize the metrics. verbose: Optional[bool] = True Whether to show a loading bar. Returns ------- 2D numpy array with metrics.""" pass
Returns all available edge prediction metrics for given edges.
The metrics returned are, in order:
- Adamic Adar index
- Jaccard Coefficient
- Resource Allocation index
- Normalized preferential attachment score
Parameters
- normalize (Optional[bool] = True): Whether to normalize the metrics.
- verbose (Optional[bool] = True): Whether to show a loading bar.
Returns
- 2D numpy array with metrics.
View Source
from __future__ import annotations from typing import * import numpy as np def okapi_bm25_tfidf_int(documents: List[List[int]], k1: Optional[float], b: Optional[float], vocabulary_size: Optional[int], verbose: Optional[bool]) -> List[Dict[int, float]]: """Return vocabulary and TFIDF matrix of given documents. Arguments --------- documents: List[List[str]], The documents to parse k1: Optional[float] The default parameter for k1, tipically between 1.2 and 2.0. b: Optional[float] The default parameter for b, tipically equal to 0.75. vocabulary_size: Optional[int] The expected vocabulary size. verbose: Optional[bool] Whether to show a loading bar.""" pass def okapi_bm25_tfidf_str(documents: List[List[str]], k1: Optional[float], b: Optional[float], vocabulary_size: Optional[int], verbose: Optional[bool]) -> List[Dict[str, float]]: """Return vocabulary and TFIDF matrix of given documents. Arguments --------- documents: List[List[str]], The documents to parse k1: Optional[float] The default parameter for k1, tipically between 1.2 and 2.0. b: Optional[float] The default parameter for b, tipically equal to 0.75. vocabulary_size: Optional[int] The expected vocabulary size. verbose: Optional[bool] Whether to show a loading bar.""" pass def word2vec(sequences: List[List[int]], window_size: int) -> Tuple[np.ndarray, np.ndarray]: """Return training batches for Word2Vec models. The batch is composed of a tuple as the following: - (Contexts indices, central nodes indices): the tuple of nodes This does not provide any output value as the model uses NCE loss and basically the central nodes that are fed as inputs work as the outputs value. Arguments --------- sequences: List[List[int]] the sequence of sequences of integers to preprocess. window_size: int Window size to consider for the sequences.""" pass
View Source
"""Module with datasets.""" from . import (kghub, linqs, monarchinitiative, networkrepository, pheknowlatorkg, yue, zenodo) from .get_dataset import (get_all_available_graphs_dataframe, get_available_graphs_from_repository, get_available_repositories, get_available_versions_from_graph_and_repository, validate_graph_version, get_dataset) __all__ = [ "get_dataset", "get_available_repositories", "get_available_graphs_from_repository", "get_all_available_graphs_dataframe", "get_available_versions_from_graph_and_repository", "validate_graph_version", "kghub", "linqs", "monarchinitiative", "networkrepository", "yue", "zenodo", "pheknowlatorkg" ]
Module with datasets.