def network(self):
     row_no = self.tableWidget.rowCount()
     column_no = self.tableWidget.columnCount()
     row_no_list = list(range(0, row_no))
     column_no_list = list(range(0, column_no))
     in_concpets = []
     out_concepts = []
     relations = []
     for i in row_no_list:
         in_concpets.append(str(self.tableWidget.item(i, 0).text()))
     for j in row_no_list:
         out_concepts.append(str(self.tableWidget.item(j, 2).text()))
     for k in row_no_list:
         relations.append(str(self.tableWidget.item(k, 1).text()))
     print(in_concpets)
     G = nx.Graph()
     for i in list(zip(in_concpets, relations, out_concepts)):
         G.add_edge(i[0], i[1])
         G.add_edge(i[1], i[2])
         G.node[i[1]]['color'] = 'green'
         G.node[i[1]]['fill'] = 'green'
     G.remove_nodes_from(['.'])
     import config
     config.graph = G
     graph = G
     Ui_MainWindow.graph = G
     app = Viewer(G)
     app.mainloop()
Пример #2
0
def draw():
    edge_list_path = r"edges.txt"
    DG = nx.read_edgelist(edge_list_path, create_using=nx.DiGraph())

    try:
        app = Viewer(DG)
        app.mainloop()
    except IndexError:
        print("(!) Citation network is empty. Try adding more papers...")
Пример #3
0
import networkx as nx
from networkx_viewer import Viewer
G = nx.DiGraph()
G.add_edge('usb_uicc_daemon','usb_uicc_daemon')
G.edge['usb_uicc_daemon']['usb_uicc_daemon']['write-read'] = '[open open][write read][append read][open open][write read][add_name search][remove_name search][setattr getattr][write read][append read][setopt getopt][open open]'
G.add_edge('usb_uicc_daemon','usb_uicc_daemon')
G.edge['usb_uicc_daemon']['usb_uicc_daemon']['write-read'] = '[open open][write read][append read][open open][write read][add_name search][remove_name search][setattr getattr][write read][append read][setopt getopt][open open][write read]'
G.edge['usb_uicc_daemon']['usb_uicc_daemon']['fill'] = 'red'
G.add_edge('usb_uicc_daemon','usb_uicc_daemon')
G.edge['usb_uicc_daemon']['usb_uicc_daemon']['write-read'] = '[open open][write read][append read][open open][write read][add_name search][remove_name search][setattr getattr][write read][append read][setopt getopt][open open][write read][append read]'
app = Viewer(G)
app.mainloop()
Пример #4
0
#app.mainloop()

## a union ##
#U = nx.Graph()
#U.add_edges_from(G.edges(data=True)+H.edges(data=True))

##U=nx.intersection(G,H)
###Ux=nx.disjoint_union(U,J)
##print U.nodes()
##app=Viewer(U)
##app.mainloop()

## MAIN ##
n = 3
T = n_disjoint_unions(G, n)

app = Viewer(T)
app.mainloop()

## I think it works!! Here is a quick rundown of the current process: takes a nx graph G and creates a disjoint union of G
## w itself n times. Then, looks thru the nodes of the new graph H and considers the degree centrality. This indicates
## that it is on the outside of the graph and can be connected to another. If it is sufficiently
## small, it adds it to a list of nodes w small degree. Then, scans thru this created list, adding edges between small degree nodes
## on each iteration of original G.

## ISSUES: 1) There are a couple nodes w less connections to other iterations, namely the first and last ones considered.
##         2) Will it work for n v large? (works n=3,5) DOES NOT WORK n=2 (a hardcoded pbm) (.1 is ideal for n=3 only)
##         3) The < value for degree centrality is currently hardcoded, based on my small test graph. Will need to be adjusted
##            for an actual street network. Is there a way to generalize this variable or should be determined empirically for each case?
##         4) A solution to above? Parse thru nodes and examine range of values to determine lowest, make if == this value.
Пример #5
0
def draw_Gui():
    app = Viewer(G)
    app.mainloop()
    # code to edit graph
    app.canvas.refresh()
Пример #6
0
def draw_graph(graph_nodes):
    app=Viewer(graph_nodes)
    app.mainloop()
Пример #7
0
def see_graph(g):
    # Viewer

    app	=	Viewer(g)
    app.mainloop()