cfpq_data.graphs.utils.edges_statistics#
Returns statistics of graph edges.
Functions
|
Returns a dictionary with the number of edge labels used in the graph. |
|
Returns a list of edge labels sorted by the number of uses in the graph. |
- get_labels_frequency(graph: MultiDiGraph) DefaultDict[Any, int][source]#
Returns a dictionary with the number of edge labels used in the graph.
- Parameters:
- graphMultiDiGraph
Given graph.
- Returns:
- labels_frequencyDefaultDict[Any, int]
Dictionary with edge labels usage frequency.
Examples
>>> from cfpq_data import * >>> g = labeled_two_cycles_graph(1, 1, labels=("a", "b")) >>> list(g.edges(data=True)) [(1, 0, {'label': 'a'}), (0, 1, {'label': 'a'}), (0, 2, {'label': 'b'}), (2, 0, {'label': 'b'})] >>> labels_frequency = get_labels_frequency(g) >>> labels_frequency defaultdict(<class 'int'>, {'a': 2, 'b': 2})
- get_sorted_labels(graph: MultiDiGraph, *, reverse: bool = False) List[Any][source]#
Returns a list of edge labels sorted by the number of uses in the graph. The labels with equal number of uses are sorted lexicographically.
- Parameters:
- graphMultiDiGraph
Given graph.
- reverse: bool
If set to True, then the labels are sorted in reverse (ascending) order.
- Returns:
- labelsList[Any]
Sorted list of graph edge labels.
Examples
>>> from cfpq_data import * >>> g = labeled_two_cycles_graph(42, 29) >>> sorted_labels = get_sorted_labels(g) >>> sorted_labels ['a', 'b']