ragraph.analysis.comparison
¶
Comparison analysis¶
Comparison provides classes for comparing Graph
objects to find the
commonalities (sigma) and differences (delta).
Comparison methods¶
sigma_graph
to calculate the commonalities (i.e. sum) of a set of graphs with comparable node names.delta_graph
to calculate the differences and overlap between two graphs with comparable node names.
EdgeDescriptor
dataclass
¶
Bases: EdgeDescriptorLike
Describe a node based on its source name, target name, kind, labels, and weights.
EdgeDescriptorLike
¶
Bases: ABC
A class that takes an edge and describes it by returning a fixed (hashable) output.
Hashable means that the description can be used to determine uniqueness by set operations.
from_edge
abstractmethod
classmethod
¶
|
NodeDescriptor
dataclass
¶
NodeDescriptorLike
¶
Bases: ABC
A class that takes a node and describes it by returning a fixed (hashable) output.
Hashable means that the description can be used to determine uniqueness by set operations.
from_node
abstractmethod
classmethod
¶
|
to_node
abstractmethod
¶
SigmaMode
¶
Bases: StrEnum
Aggregation mode for sigma analysis, absolute counted occurrences or an average per graph.
TagMode
¶
Bases: StrEnum
How to tag nodes as unique to one of the given inputs or common.
add_edges
¶
Add observed edges in item to the accumulator in-place.
Based on node names.
Metadata for existing nodes is added using
add_meta
method.
Source code in ragraph/analysis/comparison/_sigma.py
add_graph
¶
Add a graph to an accumulator graph. Occurrences are counted under the 'count_prefix'.
Source code in ragraph/analysis/comparison/_sigma.py
add_meta
¶
Add metadata of another item to the accumulator in-place. Annotations are updated and the last observed value for any key is kept. Occurrence value is tracked under the 'count_prefix'.
Source code in ragraph/analysis/comparison/_sigma.py
add_nodes
¶
Add observed nodes in item to the accumulator in-place and keep track of an occurrence count.
Based on node names.
Metadata for existing nodes is added using
add_meta
method.
Source code in ragraph/analysis/comparison/_sigma.py
delta_graph
¶
|
Get the delta graph between two graphs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graph_a
|
Graph
|
First graph to compare. |
required |
graph_b
|
Graph
|
Second graph to compare. |
required |
delta_a
|
str
|
Name for nodes and edges unique to the first graph. |
'delta_a'
|
delta_b
|
str
|
Name for nodes and edges unique to the second graph. |
'delta_b'
|
common
|
str
|
Name for the common nodes and edges occurring in both graphs. |
'common'
|
Note
Graphs are compared on leaf node level and compared by name only.
Please provide appropriate input as such and look to
get_graph_slice
for example on how to obtain a
subgraph to your liking.
Source code in ragraph/analysis/comparison/_delta.py
increment_meta
¶
Increment the occurrence and label counts as weights in the accumulator with an item.
Source code in ragraph/analysis/comparison/_sigma.py
initialize_meta
¶
Initialize an accumulator instance with the info from the first item.
Source code in ragraph/analysis/comparison/_sigma.py
sigma_graph
¶
Get the sigma (summed) graph based on the leaf nodes and the edges in multiple graphs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graphs
|
Iterable[Graph]
|
Graphs to sum and count edge occurrences in. |
required |
mode
|
SigmaMode
|
Whether to count absolute occurrence values or an average per graph. |
ABSOLUTE
|
count_prefix
|
str
|
Which weight key (prefix) to store the occurrence values under. Also used as a prefix for label counts that are stored as weights using as well. |
'sigma'
|
Note
Summations are done over (leaf) node names. Edges in an input graph are aggregated first
using the add_meta
method
before being aggregated into the resulting graph.
Source code in ragraph/analysis/comparison/_sigma.py
tag
¶
Tag an item using a given tagging mode.
Source code in ragraph/analysis/comparison/utils.py
_delta
¶
Delta analysis¶
delta_graph
¶
|
Get the delta graph between two graphs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graph_a
|
Graph
|
First graph to compare. |
required |
graph_b
|
Graph
|
Second graph to compare. |
required |
delta_a
|
str
|
Name for nodes and edges unique to the first graph. |
'delta_a'
|
delta_b
|
str
|
Name for nodes and edges unique to the second graph. |
'delta_b'
|
common
|
str
|
Name for the common nodes and edges occurring in both graphs. |
'common'
|
Note
Graphs are compared on leaf node level and compared by name only.
Please provide appropriate input as such and look to
get_graph_slice
for example on how to obtain a
subgraph to your liking.
Source code in ragraph/analysis/comparison/_delta.py
_sigma
¶
Sigma analysis¶
SigmaMode
¶
Bases: StrEnum
Aggregation mode for sigma analysis, absolute counted occurrences or an average per graph.
add_edges
¶
Add observed edges in item to the accumulator in-place.
Based on node names.
Metadata for existing nodes is added using
add_meta
method.
Source code in ragraph/analysis/comparison/_sigma.py
add_graph
¶
Add a graph to an accumulator graph. Occurrences are counted under the 'count_prefix'.
Source code in ragraph/analysis/comparison/_sigma.py
add_meta
¶
Add metadata of another item to the accumulator in-place. Annotations are updated and the last observed value for any key is kept. Occurrence value is tracked under the 'count_prefix'.
Source code in ragraph/analysis/comparison/_sigma.py
add_nodes
¶
Add observed nodes in item to the accumulator in-place and keep track of an occurrence count.
Based on node names.
Metadata for existing nodes is added using
add_meta
method.
Source code in ragraph/analysis/comparison/_sigma.py
increment_meta
¶
Increment the occurrence and label counts as weights in the accumulator with an item.
Source code in ragraph/analysis/comparison/_sigma.py
initialize_meta
¶
Initialize an accumulator instance with the info from the first item.
Source code in ragraph/analysis/comparison/_sigma.py
sigma_graph
¶
Get the sigma (summed) graph based on the leaf nodes and the edges in multiple graphs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graphs
|
Iterable[Graph]
|
Graphs to sum and count edge occurrences in. |
required |
mode
|
SigmaMode
|
Whether to count absolute occurrence values or an average per graph. |
ABSOLUTE
|
count_prefix
|
str
|
Which weight key (prefix) to store the occurrence values under. Also used as a prefix for label counts that are stored as weights using as well. |
'sigma'
|
Note
Summations are done over (leaf) node names. Edges in an input graph are aggregated first
using the add_meta
method
before being aggregated into the resulting graph.
Source code in ragraph/analysis/comparison/_sigma.py
utils
¶
Comparison analysis utilities¶
EdgeDescriptor
dataclass
¶
Bases: EdgeDescriptorLike
Describe a node based on its source name, target name, kind, labels, and weights.
EdgeDescriptorLike
¶
Bases: ABC
A class that takes an edge and describes it by returning a fixed (hashable) output.
Hashable means that the description can be used to determine uniqueness by set operations.
from_edge
abstractmethod
classmethod
¶
|
NodeDescriptor
dataclass
¶
NodeDescriptorLike
¶
Bases: ABC
A class that takes a node and describes it by returning a fixed (hashable) output.
Hashable means that the description can be used to determine uniqueness by set operations.
from_node
abstractmethod
classmethod
¶
|
to_node
abstractmethod
¶
TagMode
¶
Bases: StrEnum
How to tag nodes as unique to one of the given inputs or common.
tag
¶
Tag an item using a given tagging mode.