focals
dgm.algorithm.focals allows for finding focal sources and sinks in a graph.
Example usage
To obtain the source and sink nodes as well as a heatmap
AreaFlows
Bases: NodeFlows
radius = 10
instance-attribute
__init__(graph)
filter_area_paths(node_source, area_nodes)
Filter area nodes that have no in-area connection to the source node. i.e. all area nodes for which the source node has no connection into said area node are removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_source |
int
|
the graph nodes for which we want to filter connections |
required |
area_nodes |
ndarray
|
all nodes within its area |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: filtered area nodes |
run()
Calculate the in-, out- and contained degree of each node to an area within radius.
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray, ndarray]
|
tuple[np.ndarray]: in-, out- and contained degree |
set_radius(radius)
NodeFlows
Bases: NKAlgorithm
The In other words, the in- and out- degree for each node.
run()
Calculates the in- and out flow for each node in the graph.
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: in and out degree for each node. |
NodeSources
Calculate normalized in/out flow balance and determine if each node is a source or a sink.
contained_flows = contained_flows
instance-attribute
in_flows = in_flows
instance-attribute
out_flows = out_flows
instance-attribute
__init__(in_flows, out_flows, contained_flows)
run(min_edges=2)
Calculate normalized in/out flow balance and determine if each node is a source or a sink.
Source nodes are labeled as 1, sink nodes are labeled as -1. If the balance falls within the range [-threshold, threshold], the nodes are neither sources nor sinks and labeled as 0.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: nodes heatmap of normalized in/out flow balance |