graph-theory

What is the correct graph data structure to differentiate between nodes with the same name?

廉价感情. 提交于 2021-02-20 05:14:13
问题 I'm learning about graphs(they seem super useful) and was wondering if I could get some advice on a possible way to structure my graphs. Simply, Lets say I get purchase order data everyday and some days its the same as the day before and on others its different. For example, yesterday I had an order of pencils and erasers, I create the two nodes to represent them and then today I get an order for an eraser and a marker, and so on. After each day, my program also looks to see who ordered what,

Deleting nodes with tie=1 in a large NetworkX graph

≯℡__Kan透↙ 提交于 2021-02-18 19:11:35
问题 I have made large graph with NetworkX with about 20,000 nodes. I would like to delete nodes with only one tie (or zero ties) to try to reduce the clutter. Since it is a very large graph I do not know the nodes by name or ID that have tie=1 or 0. Does anyone know how to delete these nodes without specifying the node ID or name? 回答1: Iterating on a Graph g yields all of g 's nodes, one at a time -- I believe you can't alter g during the iteration itself, but you can selectively make a list of

Deleting nodes with tie=1 in a large NetworkX graph

扶醉桌前 提交于 2021-02-18 19:10:39
问题 I have made large graph with NetworkX with about 20,000 nodes. I would like to delete nodes with only one tie (or zero ties) to try to reduce the clutter. Since it is a very large graph I do not know the nodes by name or ID that have tie=1 or 0. Does anyone know how to delete these nodes without specifying the node ID or name? 回答1: Iterating on a Graph g yields all of g 's nodes, one at a time -- I believe you can't alter g during the iteration itself, but you can selectively make a list of

Deleting nodes with tie=1 in a large NetworkX graph

扶醉桌前 提交于 2021-02-18 19:10:10
问题 I have made large graph with NetworkX with about 20,000 nodes. I would like to delete nodes with only one tie (or zero ties) to try to reduce the clutter. Since it is a very large graph I do not know the nodes by name or ID that have tie=1 or 0. Does anyone know how to delete these nodes without specifying the node ID or name? 回答1: Iterating on a Graph g yields all of g 's nodes, one at a time -- I believe you can't alter g during the iteration itself, but you can selectively make a list of

Deleting nodes with tie=1 in a large NetworkX graph

狂风中的少年 提交于 2021-02-18 19:09:44
问题 I have made large graph with NetworkX with about 20,000 nodes. I would like to delete nodes with only one tie (or zero ties) to try to reduce the clutter. Since it is a very large graph I do not know the nodes by name or ID that have tie=1 or 0. Does anyone know how to delete these nodes without specifying the node ID or name? 回答1: Iterating on a Graph g yields all of g 's nodes, one at a time -- I believe you can't alter g during the iteration itself, but you can selectively make a list of

Arrowhead overlaps node in Graphviz

左心房为你撑大大i 提交于 2021-02-17 04:10:11
问题 When you look at the graph above you can easily see that the arrowhead from a->b overlaps the node b. The tip of the arrowhead should stop right before the b node box, like it is the case in c->d. The code that produces this result is: digraph{ node[shape="box"] a->b[color=blue, penwidth=20] c->d[color=blue] } The layout engine in use is the "dot" Layout Engine. 回答1: headclip (and tailclip) causes the center of the pen drawing the edge to stop when crossing the imaginary line drawn by the

Map-Navigation Project, How is road data generally stored/represented?

故事扮演 提交于 2021-02-15 08:51:55
问题 Navigation systems like the Garmin and TomTom have always fascinated me. I've wanted to implement small map/navigation applications to try out various pathing algorithms and expand on my knowledge of them. This is a two part question: 1.) How is Map data stored? - When you have a network of roads, how is this data generally stored? What parts of the data are retained inorder to reproduce a map later? Is each road stored as a series of points where it changes direction? What kind of file

Graph “Vertex cover” brute algorithm

风流意气都作罢 提交于 2021-02-11 17:44:49
问题 Given an electrical network, which is a set of electric generators, between which wires are stretched. A wire has current if at least one generator is operating at one end of the wire. Find the set with minimum count of generators that need to be turned on to provide current to the entire network. I found some extra information that can help. It is "Vertex cover problem". Now we know that it hasn't special algorithm. Let's bruteforce? 回答1: As you note in the question, this is an instance of

How to detect a loop in a hierarchy of javascript elements

北城以北 提交于 2021-02-10 19:19:48
问题 I have a list of elements, each has an ID and a parent ID. What I want to do is detect when there is a loop in this 'hierarchy', and show which ID starts the loop. list = [ { id: '1', parent: '2' }, { id: '2', parent: '3' }, { id: '3', parent: '4' }, { //This id is causing the loop id: '4', parent: '1' } ] I have tried this to build the tree, which works when there's no loop, but does not work with a loop: function treeify(list, idAttr, parentAttr, childrenAttr) { if (!idAttr) idAttr = 'id';

How to detect a loop in a hierarchy of javascript elements

我是研究僧i 提交于 2021-02-10 19:19:17
问题 I have a list of elements, each has an ID and a parent ID. What I want to do is detect when there is a loop in this 'hierarchy', and show which ID starts the loop. list = [ { id: '1', parent: '2' }, { id: '2', parent: '3' }, { id: '3', parent: '4' }, { //This id is causing the loop id: '4', parent: '1' } ] I have tried this to build the tree, which works when there's no loop, but does not work with a loop: function treeify(list, idAttr, parentAttr, childrenAttr) { if (!idAttr) idAttr = 'id';