Exemple #1
0
def showing_in_ubigraph(graph, vstyles=[],estyles=[]):
    """
    Dynamic visualization using Ubigraph. Server should be
    running in the URL "ubiServer"
    graph.edges is a list of tuples: (n1,n2,w)
    """
    U = ubigraph.Ubigraph(URL=ubiServer)
    U.clear()
    nodes = {}
    edges = set([])
    #maxw = float(max(np.array([i[2] for i in graph.edges()]))) #largest weight
    if not vstyles:
        vstyles = cycle([U.newVertexStyle(id=1,shape="sphere", color="#ff0000")])
    else:
        vstyles = cycle(vstyles)
    rt_style = U.newVertexStyle(id=2,shape="sphere", color="#00ff00")
    for e in graph.edges():
        if e[0] not in nodes:
            n1 = U.newVertex(style=vstyles.next(), label=str(e[0]))#.decode('latin-1'))
            nodes[e[0]] = n1
        else:
            n1 = nodes[e[0]]
        if e[1] not in nodes:
            n2 = U.newVertex(style=rt_style, label=str(e[1]))
            nodes[e[1]] = n2
        else:
            n2 = nodes[e[1]]
        #es = e[2]/maxw
        if (n1,n2) not in edges:
            #U.newEdge(n1,n2,spline=True,strength=es, width=2.0, showstrain=True)
            U.newEdge(n1,n2,spline=True, width=2.0, showstrain=True)
            edges.add((n1,n2))
            edges.add((n2,n1))
Exemple #2
0
 def __init__(self):
     self.ubi = ubigraph.Ubigraph()
     try:
         self.ubi.clear()
     except socket.error, e:
         print 'Ubigraph server seems to be not running. Please run it.'
         print e
         sys.exit(1)
Exemple #3
0
def dyn_graph_lei(elist):
    """
    Visualização dinâmica usando ubigraph
    Servidor Ubigraph deve estar rodando na URL indicada
    """
    U = ubigraph.Ubigraph(URL=ubiServer)
    U.clear()
    ''' Versão 1 '''
    v_styles = {
        'LEG-FED': U.newVertexStyle(id=1, shape="cube", color="#ff0000"),
        'LEG-EST': U.newVertexStyle(id=2, shape="cube", color="#00ff00"),
        'LEG-MUN': U.newVertexStyle(id=3, shape="cube", color="#0000ff"),
        'LEG-DIS': U.newVertexStyle(id=4, shape="cube", color="#0ff000"),
        'LEG-INT': U.newVertexStyle(id=5, shape="cube", color="#000ff0"),
        'outras': U.newVertexStyle(id=6, shape="cube", color="#f0f000"),
        'CF': U.newVertexStyle(id=6, shape="cube", color="#00ff00"),
    }
    ''' Versão 2 
    v_styles = {'CF':U.newVertexStyle(id=1,shape="sphere", color="#ff0000"),
                'LEI':U.newVertexStyle(id=2,shape="sphere", color="#00ff00"),
                'SUMULA':U.newVertexStyle(id=3,shape="sphere", color="#0000ff"),
                'REGIMENTO':U.newVertexStyle(id=4,shape="sphere", color="#0ff000"),
                }
    '''
    lei_style = U.newVertexStyle(id=1, shape="sphere", color="#ff0000")
    #Q = dbgrafo.execute(cf88_vs_outras_q)
    res = elist
    nodes = {}
    edges = set([])
    #print res[0]
    maxw = float(max(np.array([i[6] for i in res])))  #largest weight
    #U.beginMultiCall()
    c = 1
    for e in res:

        if e[0] not in nodes:
            n1 = U.newVertex(style=v_styles[e[1]], label=str(e[2]))
            nodes[e[0]] = n1
        else:
            n1 = nodes[e[0]]
        if e[3] not in nodes:
            n2 = U.newVertex(style=v_styles[e[4]], label=str(e[5]))
            nodes[e[3]] = n2
        else:
            n2 = nodes[e[3]]
        es = e[6] / maxw
        if (n1, n2) not in edges:
            U.newEdge(n1,
                      n2,
                      spline=True,
                      strength=es,
                      width=2.0,
                      showstrain=True)
            edges.add((n1, n2))
            edges.add((n2, n1))
        c += 1
 def animateGraph(self, hostName):
     U = ubigraph.Ubigraph()
     U.clear()
     edge_list = []
     node_set = {}
     edge_count = {}
     transition_node = None
     last_line_processed = None
     filename = self.drawGraph(U, edge_list, node_set, edge_count,
                               transition_node, last_line_processed,
                               hostName)
     return filename
import ubigraph

U = ubigraph.Ubigraph()
U.clear()

x = U.newVertex(shape="sphere", color="#ffff00")

smallRed = U.newVertexStyle(shape="sphere", color="#ff0000", size="0.2")

previous_r = None
for i in range(0, 10):
    r = U.newVertex(style=smallRed, label=str(i))
    U.newEdge(x, r, arrow=True)
    if previous_r != None:
        U.newEdge(r, previous_r, spline=True, stroke="dashed")
    previous_r = r
 def __init__(self):
     self.U = ubigraph.Ubigraph()
     self.U.clear()
     self.nodes = {}
     self.edges = {}
	def __init__(self,host="127.0.0.1"):
		self.host = host
		self.api = ubigraph.Ubigraph("http://%s:20738/RPC2" % self.host)
Exemple #8
0
    print "LOGX " + str(data)

if ubi:
    import ubigraph
    from SimpleXMLRPCServer import SimpleXMLRPCServer

    ubiserver = "10.0.0.5"
    #ubiserver = "localhost"    
    callbackip = "10.0.0.10"
    #callbackserver = "localhost"

    callbackport = random.randint(20739,20999)
    print "ubigraph server is " + "http://" + ubiserver + ":20738"
    print "callback server is " + "http://" + callbackip + ":" + str(callbackport)

    G = ubigraph.Ubigraph('http://' + ubiserver  +':20738/RPC2')
    G.clear()
    
    server = SimpleXMLRPCServer(("0.0.0.0", callbackport))
    #server.register_introspection_functions()

    def myhex(i):
        return hex(i)[2:]
    
    def vertex_callback(v):
        select(v) 
        steps = 10
        for i in range(0,steps):
            time.sleep(0.01)
#            color = 191 - ((i / (10 / math.sqrt(191))) * (i / (10 / math.sqrt(191))) )
#            color = "#" + myhex(64 + int(color)) + "5c71"