-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloops _triads.py
39 lines (32 loc) · 1.21 KB
/
loops _triads.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pandas as pd
import numpy as np
import networkx as nx
import seaborn as sns
import matplotlib.pyplot as plt
from collections import Counter
import time
strong = nx.read_edgelist('data/LSCC.edgelist',
data=(("total",float),("count", int)), create_using=nx.DiGraph)
weak = nx.read_edgelist('data/LWCC.edgelist',
data=(("total",float),("count", int)), create_using=nx.DiGraph)
print('Read file compelted')
def calculate_loops(G,max_step):
out = nx.simple_cycles(G,max_step)
length_of_circles = [len(i) for i in out]
out = Counter(length_of_circles)
return out
# start_time = time.time()
# out = calculate_loops(G,5)
# print(out)
# print("--- %s mins ---" % round((time.time() - start_time)/60,2))
#------------This is where we start to explore number of di triangles----------
# start_time = time.time()
# out = nx.triadic_census(strong)
# for key, value in out.items():
# print(f"{key}: {value}")
# print("--- %s mins ---" % round((time.time() - start_time)/60,2))
# start_time = time.time()
# out = nx.triadic_census(weak)
# for key, value in out.items():
# print(f"{key}: {value}")
# print("--- %s mins ---" % round((time.time() - start_time)/60,2))