topologic package¶
-
topologic.
connected_components_generator
(graph: networkx.classes.graph.Graph) → Generator[networkx.classes.graph.Graph, None, None][source]¶ Returns a Generator that will provide each component as a networkx.Graph copy
Parameters: graph (networkx.Graph) – The networkx graph object to create a connected component generator from Returns: A Generator that returns a copy of the subgraph corresponding to a connected component of graph Return type: Generator[networkx.Graph]
-
exception
topologic.
DialectException
(message)[source]¶ Bases:
BaseException
-
exception
topologic.
InvalidGraphError
(message)[source]¶ Bases:
BaseException
-
topologic.
largest_connected_component
(graph: networkx.classes.graph.Graph, weakly: bool = True) → networkx.classes.graph.Graph[source]¶ Returns the largest connected component of the graph.
Parameters: - graph (networkx.Graph) – The networkx graph object to select the largest connected component from. Can be either directed or undirected.
- weakly (bool) – Whether to find weakly connected components or strongly connected components for directed graphs.
Returns: A copy of the largest connected component as an nx.Graph object
Return type:
-
topologic.
number_connected_components
(graph: networkx.classes.graph.Graph) → int[source]¶ Returns the number of connected components in the Graph.
This function calls the appropriate newtorkx connected components function depending on whether it is Undirected or Directed.
Parameters: graph (networkx.Graph) – The networkx graph object to determine the number of connected components for Returns: number of connected components (and in the case of a directed graph, strongly connected) Return type: int
-
class
topologic.
PartitionedGraph
[source]¶ Bases:
tuple
A PartitionedGraph combines a networkx graph object with a global community partitioning for that graph.
-
community_partitions
¶ Alias for field number 1
-
graph
¶ Alias for field number 0
-
-
topologic.
self_loop_augmentation
(graph: networkx.classes.graph.Graph, weight_column: str = 'weight') → networkx.classes.graph.Graph[source]¶ Generates a self loop for each vertex in the graph with a generated weight for each vertex that is the ratio between its degree in the graph and the total number of other vertices in the graph, excluding the original self loop.
This should be used prior to Spectral Embedding techniques to ensure that there is a reasonable value for each vertex as it will appear in an adjacency matrix.
Modifies the provided graph in place as well as returning it.
Parameters: - graph (networkx.Graph) – The networkx graph to diagonally augment
- weight_column (str) – The weight column to augment
Returns: The networkx Graph object that was modified in place.
Return type:
-
exception
topologic.
UnweightedGraphError
(message)[source]¶ Bases:
BaseException