src.utils.construct_graph

Construct a graph from a DataFrame and find storylines in it.

Functions

build_graph_from_adj_list(adj_list, adj_weights)

Build a graph from an adjacency list.

edge_boundary(graph, nbunch1[, nbunch2])

Return the edge boundary of two sets of nodes ina rustworkx graph.

filter_interstory_connections(graph, storylines)

Filter interstory connections from the graph.

normalize_adj_weights(graph)

Normalize the weights of the edges in the graph.

transitive_reduction(graph, storylines)

Perform transitive reduction on the graph within storylines.

src.utils.construct_graph.build_graph_from_adj_list(adj_list, adj_weights)[source]

Build a graph from an adjacency list.

Parameters:
  • adj_list (Sequence[Sequence[int]]) – The adjacency list.

  • adj_weights (Sequence[Sequence[float]]) – The weights of the edges.

Return type:

PyDiGraph

Returns:

The graph as a directed graph.

src.utils.construct_graph.transitive_reduction(graph, storylines)[source]

Perform transitive reduction on the graph within storylines.

Parameters:
  • graph (PyDiGraph) – The graph to perform transitive reduction on.

  • storylines (list[list[int]]) – The story lines.

Return type:

PyDiGraph

Returns:

The graph after transitive reduction.

src.utils.construct_graph.edge_boundary(graph, nbunch1, nbunch2=None)[source]

Return the edge boundary of two sets of nodes ina rustworkx graph. Should be functionally equivalent to networkx.edge_boundary.

Parameters:
  • graph (PyDiGraph) – The graph to get the edge boundary from.

  • nbunch1 (Iterable[int]) – The first set of nodes.

  • nbunch2 (Iterable[int] | None) – The second set of nodes.

Return type:

list[tuple[int, int]]

Returns:

The edge boundary of the two sets of nodes.

src.utils.construct_graph.filter_interstory_connections(graph, storylines)[source]

Filter interstory connections from the graph.

This function filters out interstory connections from the graph.

Parameters:
  • graph (PyDiGraph) – The graph to filter interstory connections from.

  • storylines (list[list[int]]) – The story lines.

Return type:

PyDiGraph

Returns:

The graph after filtering interstory connections.

src.utils.construct_graph.normalize_adj_weights(graph)[source]

Normalize the weights of the edges in the graph.

Parameters:

graph (PyDiGraph) – The graph to normalize the weights of.

Return type:

PyDiGraph

Returns:

The graph with normalized weights.