You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to use snap.GenRewire to create an ensemble of thousands of rewired graphs from one base graph and I'm running into a problem with the "time limit."
A simplified example is as follows: I have the adjacency matrix for G as a numpy array, so I have created the following function to create a TUNGraph from the adjacency matrix, rewire the graph with GenRewire, then regenerate an adjacency matrix as a numpy array:
def rewire(G_adj):
N = G_adj.shape[0]
G = snap.TUNGraph.New()
for i in range(N):
G.AddNode(i)
for i in range(N):
for j in range(N):
if G_adj[i,j] == 1:
G.AddEdge(i,j)
G_rewire = snap.GenRewire(G,100)
G_rewire_adj = np.zeros_like(W)
for edge in G_rewire.Edges():
G_rewire_adj[edge.GetSrcNId(),edge.GetDstNId()] = 1
G_rewire_adj[edge.GetDstNId(),edge.GetSrcNId()] = 1
return G_rewire_adj
I am then iterating with a for loop to generate each new rewired graph:
G_adj = np.load('path/to/G_adj.npy')
for i in range(1000):
G_rewired = rewire(G_adj)
np.save(f'path/to/G_rewired_{i}',G_rewired)
G_adj has 572 nodes and roughly 160000 edges.
The problem I'm running into is that for each iteration, GenRewire prints out its status update with a time code that increases from where the last iteration left off, meaning that even though any given iteration only takes a few seconds, the printed time code quickly reaches the 2h0m mark at which point it seems hard coded to give a "Time limit!" warning and stop rewiring for all future iterations. If I run the code again in the same Python interpreter, all iterations give the "time limit" warning, but if I start a new interpreter, the first iterations proceed as normal until the accumulated time count reaches 2 hours.
Could someone help me understand this behavior? Why is there a connection in the time count between presumably separate Graph constructions / rewirings? Do I need to include some call to clear or delete each graph after I am done with it?
Thanks for your help!
The text was updated successfully, but these errors were encountered:
Yes, GenRewire() has a 2 hour limit. This limit should be restarted for each new call to GenRewire(). The code below, a simplified version of your example, is able to replicate your problem. The timer switches between iterations 83-84 and 254-255. We will investigate the problem.
import snap
def rewire(G_in):
G = G_in.ConvertGraph(snap.TUNGraph)
G_rewire = snap.GenRewire(G,1000)
return G_rewire
G_in = snap.GenFull(snap.TNGraph, 572)
for i in range(500):
G_rewired = rewire(G_in)
print(i, G_rewired.GetNodes(), G_rewired.GetEdges())
There was a problem with the timer overflow for long running processes. This has been fixed in the C++ code. The fix will be available in our next update, which we plan to release in a few weeks.
I am attempting to use snap.GenRewire to create an ensemble of thousands of rewired graphs from one base graph and I'm running into a problem with the "time limit."
A simplified example is as follows: I have the adjacency matrix for G as a numpy array, so I have created the following function to create a TUNGraph from the adjacency matrix, rewire the graph with GenRewire, then regenerate an adjacency matrix as a numpy array:
I am then iterating with a for loop to generate each new rewired graph:
G_adj has 572 nodes and roughly 160000 edges.
The problem I'm running into is that for each iteration, GenRewire prints out its status update with a time code that increases from where the last iteration left off, meaning that even though any given iteration only takes a few seconds, the printed time code quickly reaches the 2h0m mark at which point it seems hard coded to give a "Time limit!" warning and stop rewiring for all future iterations. If I run the code again in the same Python interpreter, all iterations give the "time limit" warning, but if I start a new interpreter, the first iterations proceed as normal until the accumulated time count reaches 2 hours.
Could someone help me understand this behavior? Why is there a connection in the time count between presumably separate Graph constructions / rewirings? Do I need to include some call to clear or delete each graph after I am done with it?
Thanks for your help!
The text was updated successfully, but these errors were encountered: