Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions scc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pickle
import networkx as nx

# Use networkx strongly_connected_components() function to separate graph
with open("data/graph.pkl", "rb") as f:
G = pickle.load(f)

SCCs = list(nx.strongly_connected_components(G))

# Print notable details
print(f"Number of SCCs: {len(SCCs)}")
print(f"Largest SCC size: {max(len(SCC) for SCC in SCCs)}")

# Find SCCs with multiple vertices
counter = 0
for SCC in SCCs:
if len(SCC) != 1:
counter += 1
print(f"Size of SCC {counter}: {len(SCC)}")

print(f"Number of SCCs with multiple vertices", counter)