edges

Build tree from edges

与世无争的帅哥 提交于 2019-12-06 13:52:47
I have the edges and i want to build a tree with it. The problem is that i can construct my tree structure only when edges are in specific order. Example of orders: (vertex, parent_vertex) good: bad: (0, ) <-top (3, 2) (1, 0) (1, 0) (2, 1) (3, 2) (3, 2) (0, ) <-top I iterate throw the edges and for current vertex trying to find it's parent in created tree, then i construct the node and insert it. result tree: 0 - 1 - 2 - 3 So there is always must exist a parent in the tree for the new added vertex. The question is how to sort the input edges. Voices tells me about the topological sort, but it

Python networkx : edge contraction

不问归期 提交于 2019-12-06 02:04:01
问题 I have a NetworkX graph. I would like to know how to do edge contraction between multiple nodes. For example, if I wanted to contract X, Y and Z: _ node A _ _/ | \_ node X --- node Y --- node Z Would become node A | node XYZ (or whatever X/Y/Z) Graph creation is not the problem. It works. I want to reduce the graph by merging nodes that have the same "meanings": nodes that I call "end lvl" (node name length is equal to 7) and that are linked together. I have found the condensation function in

In OpenGL ES 2.0, how can I draw a wireframe of triangles except for the lines on adjacent coplanar faces?

最后都变了- 提交于 2019-12-05 15:37:51
I vaguely remember seeing something in OpenGL (not ES, which was still at v1.0 on the iPhone when I came across this, which is why I never used it) that let me specify which edges of my polygons were considered outlines vs those that made up the interior of faces. As such, this isn't the same as the outline of the entire model (which I know how to do), but rather the outline of a planar face with all its tris basically blended into one poly. For instance, in a cube made up of tri's, each face is actually two tris. I want to render the outline of the square, but not the diagonal across the face

Jung coloring vertex with value

强颜欢笑 提交于 2019-12-05 03:24:08
I'm stuck at the moment with the Java library Jung. I display vertices and edges, only I can not find any functions for vertex coloring that I need with the value of the vertices and not with the mouse. import edu.uci.ics.jung.algorithms.layout.FRLayout; import edu.uci.ics.jung.algorithms.layout.Layout; import edu.uci.ics.jung.graph.Graph; import edu.uci.ics.jung.visualization.BasicVisualizationServer; import edu.uci.ics.jung.visualization.decorators.PickableVertexPaintTransformer; import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; import edu.uci.ics.jung.visualization

Python networkx : edge contraction

与世无争的帅哥 提交于 2019-12-04 05:30:00
I have a NetworkX graph. I would like to know how to do edge contraction between multiple nodes. For example, if I wanted to contract X, Y and Z: _ node A _ _/ | \_ node X --- node Y --- node Z Would become node A | node XYZ (or whatever X/Y/Z) Graph creation is not the problem. It works. I want to reduce the graph by merging nodes that have the same "meanings": nodes that I call "end lvl" (node name length is equal to 7) and that are linked together. I have found the condensation function in NetworkX so I tried to use it: # edge contraction for same nodes # for each node, get the links to

How to draw parallel edges in Networkx / Graphviz

社会主义新天地 提交于 2019-12-03 15:47:44
I am trying to add parallel edges between two nodes using NetworkX but it fails with the below error. What am I doing wrong? import networkx as nx import graphviz g1 = nx.MultiGraph() node1 = 'a' node2 = 'b' g1.add_edge(node1,node2,key='one') g1.add_edge(node1,node2,key='two') A = nx.to_agraph(g1) A.add_subgraph() A.draw('test2.png', prog='dot') Error: Traceback (most recent call last): File "test2.py", line 12, in <module> A = nx.to_agraph(g1) File "C:\python27\lib\site-packages\networkx-1.11rc1-py2.7.egg\networkx\drawing\nx_agraph.py", line 152, in to_agraph A.add_edge(u,v,key=str(key),**str

Cumulative value of an edge or node attribute while descending an igraph object

二次信任 提交于 2019-12-02 11:16:11
问题 I have an igraph object g made from dataframe df : df <- data.frame(c(0,1,2,2,4), c(1,2,3,4,5), c(0.01, 0.03, 0.05, 0.01, 0.02)) colnames(df) <- c('parent_id', 'id', 'dt') g <- graph_from_data_frame(df) Edges are made between parent_id and id . > g IGRAPH DN-- 6 5 -- + attr: name (v/c), dt (e/n) + edges (vertex names): [1] 0->1 1->2 2->3 2->4 4->5 Change in thickness dt is the edge attribute. This can be thought of as the change in thickness between a 'parent' and 'child' iceberg (this is my

Gremlin: adding edges between nodes having the same property

烂漫一生 提交于 2019-12-02 10:12:43
问题 I am very new to Gremlin. I am trying to build a graph on DSE graph using Gremlin. I am able to create the vertices: a = graph.addVertex(label, 'label1', 'key', 1) b = graph.addVertex(label, 'label1', 'key', 2) c = graph.addVertex(label, 'label2', 'key', 1) d = graph.addVertex(label, 'label2', 'key', 2) Now i am looking to automatically add edges between two nodes with differents label where the property 'key' matches (i.e create and edge between a and c, and between b and c). I am stuggling

Cumulative value of an edge or node attribute while descending an igraph object

点点圈 提交于 2019-12-02 06:51:23
I have an igraph object g made from dataframe df : df <- data.frame(c(0,1,2,2,4), c(1,2,3,4,5), c(0.01, 0.03, 0.05, 0.01, 0.02)) colnames(df) <- c('parent_id', 'id', 'dt') g <- graph_from_data_frame(df) Edges are made between parent_id and id . > g IGRAPH DN-- 6 5 -- + attr: name (v/c), dt (e/n) + edges (vertex names): [1] 0->1 1->2 2->3 2->4 4->5 Change in thickness dt is the edge attribute. This can be thought of as the change in thickness between a 'parent' and 'child' iceberg (this is my problem/project). list.edge.attributes(g) [1] "dt" to visualize: plot(g, edge.label=E(g)$dt) Example of

Gremlin: adding edges between nodes having the same property

徘徊边缘 提交于 2019-12-02 05:03:52
I am very new to Gremlin. I am trying to build a graph on DSE graph using Gremlin. I am able to create the vertices: a = graph.addVertex(label, 'label1', 'key', 1) b = graph.addVertex(label, 'label1', 'key', 2) c = graph.addVertex(label, 'label2', 'key', 1) d = graph.addVertex(label, 'label2', 'key', 2) Now i am looking to automatically add edges between two nodes with differents label where the property 'key' matches (i.e create and edge between a and c, and between b and c). I am stuggling to do that. I tried to do the following g.V().hasLabel("label1").sideEffect{g.V().("label2").has("key"