ragraph.analysis.comparison
#
Comparison provides classes for comparing Graph <ragraph.graph.Graph
objects
to find the commonalities (sigma) and differences (delta).
Submodules#
Package Contents#
Classes#
Basic class for performing a delta analysis on two Graph objects. |
|
Basic class to perform a sigma analysis on |
Functions#
|
Checks if two edges are equal based on source, target, kind, labels. |
|
Get common leafs in graph a and b |
|
Get unique edges in graph a. |
|
Get unique leafs in graph a. |
- class ragraph.analysis.comparison.DeltaAnalysis(graph_a: ragraph.graph.Graph, graph_b: ragraph.graph.Graph)#
Basic class for performing a delta analysis on two Graph objects.
- Parameters:
graph_a – Base graph object for comparison.
graph_b – Reference graph object for comparison.
Note
Graphs are compared on leaf node level, where node names are used to determine if nodes are unique or not.
- property graph_a: ragraph.graph.Graph#
Graph A to be compared.
- property graph_b: ragraph.graph.Graph#
Graph B to be compared.
- property unq_leafs_a: List[ragraph.node.Node]#
List of leafs that are only present in graph a.
- property unq_leafs_b: List[ragraph.node.Node]#
List of leafs that are only present in graph b.
- property cm_leafs_ab: List[ragraph.node.Node]#
List of leafs that are present in graph a and b.
- property unq_edges_a: List[ragraph.edge.Edge]#
List of edges that are only present in graph a.
- property unq_edges_b: List[ragraph.edge.Edge]#
List of edges that are only present in graph b.
- property cm_edges_ab: List[ragraph.edge.Edge]#
List of edges that are present in both graphs.
- property node_dict: Dict[str, ragraph.node.Node]#
Dictionary from node name to Node object
- property nodes: List[ragraph.node.Node]#
List of nodes of the delta graph.
- property edges: List[ragraph.edge.Edge]#
List of edges of the delta graph.
- _reset_lazy_props()#
Reset all lazy properties.
- _add_node(n: ragraph.node.Node, kind: str) None #
Add Node to Delta Graph.
- _add_edge(e: ragraph.edge.Edge, kind: str) None #
Add edge to Delta Graph.
- class ragraph.analysis.comparison.SigmaAnalysis(graphs: List[ragraph.graph.Graph], mode: str = 'fraction')#
Basic class to perform a sigma analysis on
ragraph.graph.Graph
objects.- Parameters:
graphs – List of graphs to compare. mode: One of “absolute” or “fraction”.
mode – Determines whether edge label overlap should be calculated as an absolute count over all edges between certain nodes or whether a fraction (percentage of label occurrence) is calculated as edge weights. Defaults to fraction.
Note
Graphs are compared on leaf node level. The resulting sigma or overlap is currently only calculated in terms of overlapping edge labels.
Note
Apart of label occurence, the overall edge occurence is also added as an Edge weight, named “_occurence”. (The underscore prefix is added so it doesn’t collide with regular label names)
- property graphs: List[ragraph.graph.Graph]#
List of graphs to be compared.
- property mode: str#
Edge weight mode.
- property nodes: List[ragraph.node.Node]#
List of leaf nodes within the graph.
- property node_dict: Dict[str, ragraph.node.Node]#
Dictionary of node name to node.
- property edges: List[ragraph.edge.Edge]#
- property edge_dict: Dict[Tuple[str, str], List[ragraph.edge.Edge]]#
Dictionary of source and target names to list of edges.
- _reset_lazy_props()#
Reset all lazy properties.
- _get_edge_weights(edges: List[ragraph.edge.Edge]) Dict[str, Union[int, float]] #
Compute weights for edge in Sigma DSM from the provided list of edges.
- ragraph.analysis.comparison.check_edge_equality(a: ragraph.edge.Edge, b: ragraph.edge.Edge) bool #
Checks if two edges are equal based on source, target, kind, labels.
- Parameters:
a – Edge a.
b – Edge b
- Returns:
Whether edges are considered equal.
- ragraph.analysis.comparison.get_common_leafs(a: ragraph.graph.Graph, b: ragraph.graph.Graph, ue: List[ragraph.edge.Edge]) List[ragraph.node.Node] #
Get common leafs in graph a and b
- Parameters:
a – Graph object.
b – Graph object.
ue – List of unique edges.
- Returns:
List of common leafs in graphs a and b.
- ragraph.analysis.comparison.get_unique_edges(a: ragraph.graph.Graph, b: ragraph.graph.Graph) List[ragraph.edge.Edge] #
Get unique edges in graph a.
- Parameters:
a – Graph object.
b – Graph object.
- Returns:
List of unique edges in a.
- ragraph.analysis.comparison.get_unique_leafs(a: ragraph.graph.Graph, b: ragraph.graph.Graph) List[ragraph.node.Node] #
Get unique leafs in graph a.
- Parameters:
a – Graph object.
b – Graph object.
- Returns:
List of unique leafs in Graph a.