sandialabs / pyrocs

pyRoCS is a library of functions used to support resilience analysis of complex systems. The package contains example datasets and tutorial to help demonstrate how the functions can be used.
https://sandialabs.github.io/pyrocs/
Other
3 stars 1 forks source link

Allow both directed and undirected in graph metrics #10

Closed ThomasWomack closed 6 months ago

ThomasWomack commented 7 months ago

Change the three graph metric functions in pyrocs/complex_systems/causal_complexity.py to allow both directed and undirected graphs in a similar way to the grc.py, with a boolean "directed" argument. Right now, functions assume the type of graph, which affects the number of edges, and presence of cycles. A directed graph with edges from A->B and B->A has two edges, but the undirected version has one edge, though they both generate the same numpy matrix. Also, the directed version has a cycle, whereas the undirected version doesn't.

cyclomatic_complexity assumes the graph is undirected and feedback_density assumes the graph is directed. Metrics will be incorrect when the matrix is generated by a different type from the one assumed by the function. causal_complexity, which uses both functions, is not correct for either type of graph.

Alternative fix: Change cyclomatic_complexity to create directed graph instead of undirected, if the intention behind all the metrics, is that they only take directed graphs.

Questions to answer