Mercurial > repos > laurenmarazzi > netisce_test
comparison tools/myTools/bin/FVS_python3/FVS_test.py @ 1:7e5c71b2e71f draft default tip
Uploaded
| author | laurenmarazzi |
|---|---|
| date | Wed, 22 Dec 2021 16:00:34 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:f24d4892aaed | 1:7e5c71b2e71f |
|---|---|
| 1 ''' | |
| 2 This file contains test cases to test the FVS function. | |
| 3 ''' | |
| 4 | |
| 5 import networkx as nx | |
| 6 import random | |
| 7 from FVS_python3 import FVS as FVS | |
| 8 | |
| 9 | |
| 10 #A random graph example | |
| 11 N=6 | |
| 12 M=12 | |
| 13 G1=nx.gnm_random_graph(N, M, seed=None, directed=True) | |
| 14 #calculate FVS | |
| 15 G1_FVS=FVS.FVS(G1) | |
| 16 print(G1.edges()) | |
| 17 print(G1_FVS) | |
| 18 | |
| 19 #A fixed graph example, the solution should be ['A'] | |
| 20 G2=nx.DiGraph() | |
| 21 G2.add_edges_from([('A','B'),('B','C'),('C','A'),('A','D'),('D','A')]) | |
| 22 #calculate FVS | |
| 23 G2_FVS=FVS.FVS(G2) | |
| 24 print(G2.edges()) | |
| 25 print(G2_FVS) | |
| 26 | |
| 27 #A three node feedback loops. The solution could be any node. | |
| 28 #With fixed randomseed, one should get the same answer. | |
| 29 G3=nx.DiGraph() | |
| 30 G3.add_edges_from([('A','B'),('B','C'),('C','A')]) | |
| 31 #calculate FVS | |
| 32 G3_FVS=FVS.FVS(G3, T_0=0.6, alpha=0.99, maxMvt_factor=5, maxFail=50, randomseed=1) | |
| 33 print(G3.edges()) | |
| 34 print(G3_FVS) |
