ragraph.analysis.cluster#

Clustering algorithms detect (nested) clusters of nodes in graphs that are relatively tightly connected by means of their edges. Both hierarchical and flat clustering algorithms are provided.

Apart of algorithm specific parameters, all of them feature the same basic parameters:

  • graph: Graph to cluster containing the relevant nodes and edges.

  • leafs: Optional list of leaf nodes to cluster. If not provided all the graph’s leaf nodes are selected.

  • inplace: Boolean toggle whether to create the new cluster nodes in the provided graph or provided a deepcopy of the graph with only the leaf nodes, their edges and newly created cluster nodes.

Available algorithms#

The following algorithms are directly accessible after importing ragraph.analysis.cluster:

  • markov(): Markov Clustering (Flat) algorithm.

  • hierarchical_markov(): Hierarchical Markov Clustering algorithm.

  • tarjans_scc(): Tarjan’s Strongly Connected Components algorithm.

Submodules#

Package Contents#

Functions#

hierarchical_markov(→ Tuple[ragraph.graph.Graph, ...)

markov(→ Tuple[ragraph.graph.Graph, ...)

tarjans_scc(→ Tuple[ragraph.graph.Graph, ...)

ragraph.analysis.cluster.hierarchical_markov(graph: ragraph.graph.Graph, root: Optional[Union[str, ragraph.graph.Node]] = None, leafs: Optional[Union[List[ragraph.graph.Node], List[str]]] = None, inherit: bool = True, loops: bool = False, edge_weights: Optional[List[str]] = None, alpha: int = markov_params['alpha'].default, beta: float = markov_params['beta'].default, mu: float = markov_params['mu'].default, max_iter: int = markov_params['max_iter'].default, symmetrize: bool = markov_params['symmetrize'].default, inplace: bool = True, names: bool = False, safe: bool = True, **kwargs) Tuple[ragraph.graph.Graph, Union[List[ragraph.graph.Node], List[str]]]#
ragraph.analysis.cluster.markov(graph: ragraph.graph.Graph, root: Optional[Union[str, ragraph.graph.Node]] = None, leafs: Optional[Union[List[ragraph.graph.Node], List[str]]] = None, inherit: bool = True, loops: bool = False, edge_weights: Optional[List[str]] = None, alpha: int = markov_params['alpha'].default, beta: float = markov_params['beta'].default, mu: float = markov_params['mu'].default, max_iter: int = markov_params['max_iter'].default, symmetrize: bool = markov_params['symmetrize'], inplace: bool = True, names: bool = False, safe: bool = True, **kwargs) Tuple[ragraph.graph.Graph, Union[List[ragraph.graph.Node], List[str]]]#
ragraph.analysis.cluster.tarjans_scc(graph: ragraph.graph.Graph, root: Optional[Union[str, ragraph.node.Node]] = None, leafs: Optional[Union[List[ragraph.node.Node], List[str]]] = None, inherit: bool = True, loops: bool = False, edge_weights: Optional[List[str]] = None, inplace: bool = True, names: bool = False, safe: bool = True, **kwargs) Tuple[ragraph.graph.Graph, Union[List[ragraph.node.Node], List[str]]]#