def main(args): filename = sys.argv[1] filepath = '/home/shridhar/Acads/5245/net-enlightenment/python/graphml-data/' + filename + '.graphml' G1 = read_graphml_file(filepath) print G1.nodes() print "number of edges = ", len(G1.edges()) G_list = [] num_certain_graphs_generated = 100 #generate a bunch of certain graphs based on probability for i in range(0,num_certain_graphs_generated): G = nx.DiGraph() for u,v in G1.edges(): if not G.has_edge(u,v): edge_dict = G1[u][v] if "weight" not in edge_dict: edge_dict = edge_dict[0] if edge_dict['weight']: if random.random() < edge_dict['weight']: G.add_edge(u, v, weight=edge_dict['weight']) #M, clusters = networkx_mcl(G, expand_factor = 2,inflate_factor =2 , max_loop = 60,mult_factor = 2) #print "output matrix = ", M #print "cluster node mapping:", clusters G_list.append(G) for i in range(0,len(G_list)): print_edgelist_graph(G_list[i], filename + "-certain-" + str(i) + ".edgelist") print_graphml_graph(G_list[i], filename + "-certain-" + str(i) + ".graphml") G_dedup = threshold_graph(G1, 0) print G_dedup.nodes() print "number of edges = ", len(G_dedup.edges()) for i in range(1,3): thresh = i/10.0 G_thresh = threshold_graph(G1, thresh) print_edgelist_graph(G_thresh,filename +"thresh-"+str(thresh) + ".edgelist") print_graphml_graph(G_thresh,filename +"thresh-"+str(thresh) + ".graphml")
if(nodeClusterList[p][i] == nodeClusterList[p][j]): weight = clust_rel_list[p][nodeClusterList[p][i]] weighted_edge_list[index][2]['weight'] += weight index+=1 return weighted_edge_list #tests path = "/home/shridhar/Acads/5245/net-enlightenment/python/intermediate_graphs/" orig_graph_name = "127_session_2" num_sets = 10 num_nodes = 116 Glist = [] n_c_map_list = [] for i in range(0,num_sets): graph_file = path+orig_graph_name + "-certain-" + str(i) + ".graphml" G = read_graphml_file(graph_file) community_file = path+orig_graph_name+"-certain-" + str(i) + ".edgelist.txt.communities" c_n_map = create_comm_node_mapping(G,community_file,False) n_c_map = create_node_comm_mapping(c_n_map) Glist.append(G) n_c_map_list.append(n_c_map) final_map = weighted_cons(Glist, n_c_map_list, num_nodes) G = nx.from_edgelist(final_map) out_f = orig_graph_name+"consensus_weighted_graph.gexf" nx.write_gexf(G,out_f) #for tup in final_map: # out_f.write(str(tup)+"\n") #print ("\n".join(final_map))