Skip to content

Commit c6afaa9

Browse files
committed
out alpha index computed with planar and non planar formula
1 parent bc840e7 commit c6afaa9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

netsyn/netsyn_syntenyFinder.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,23 @@ def compute_alpha_index(maxi_graph, cluster_vertexs):
395395

396396
nb_nodes = len(cluster_vertexs)
397397
nb_edges = cluster_graph.ecount()
398+
nb_component = len(cluster_graph.connected_components())
399+
400+
if nb_nodes <= 2:
401+
# use to prevent div by zero
402+
alpha_index_non_planar = 0
403+
404+
else:
405+
alpha_index_non_planar = (nb_edges - nb_nodes + nb_component) / ( (nb_nodes * (nb_nodes -1) / 2 ) - (nb_nodes - 1) )
398406

399-
alpha_index = (nb_edges - nb_nodes) / ( (nb_nodes * (nb_nodes -1) / 2 ) - (nb_nodes - 1) )
400407

401-
# # Formula for planar graph
402-
# nb_component = len(cluster_graph.components()) # should be 0
403-
# nb_cycle = nb_edges - nb_nodes + nb_component
404-
# alpha_index = nb_cycle / (2 * nb_edges - 5)
408+
print('alpha index, non planar graph', alpha_index_non_planar)
409+
# Formula for planar graph
410+
nb_cycle = nb_edges - nb_nodes + nb_component
411+
alpha_index_planar = nb_cycle / (2 * nb_nodes - 5)
405412

406-
return round(alpha_index, 2)
413+
print('alpha index, planar graph', alpha_index_planar)
414+
return f'planar: {round(alpha_index_planar, 2)}, non planar: {round(alpha_index_non_planar, 2)}'
407415

408416

409417
def run(PROTEINS, TARGETS, GCUSER, GAP, CUTOFF, ADVANCEDSETTINGSFILENAME):

0 commit comments

Comments
 (0)