directed-graph

Storing a directed graph in google appengine datastore

强颜欢笑 提交于 2019-12-03 03:43:38
I need to store a large and dynamic undirected graph in google appengine, what's the best way to do this? The graph representation must be able to support rapidly pulling out a set of vertices (for rendering on a page) and all the links from a specific vertex, and pathfinding across the graph (although the optimal path isn't really needed, just a fairly good one) My thoughts on the subject: The most obvious way is to have a vertex model, and an edge model which references two vertices, however that sounds like it's going to end up using an awful lot of queries for every operation, I'm

Tarjan's strongly connected components algorithm in python not working

我怕爱的太早我们不能终老 提交于 2019-12-03 03:12:55
I implemented the Tarjan's strongly connected components algorithm, according to wikipedia , in Python, but it isn't working. The algorithm is quite short and I cannot find any difference, so I cannot tell why it isn't working. I tried to check the original paper, but could not find it. Here is the code. def strongConnect(v): global E, idx, CCs, c, S idx[v] = (c, c) #idx[v][0] for v.index # idx[v][1] for v.lowlink c += 1 S.append(v) for w in [u for (v2, u) in E if v == v2]: if idx[w][0] < 0: strongConnect(w) # idx[w] = (idx[w][0], min(idx[v][1], idx[w][1])) #fixed, thx idx[v] = (idx[v][0], min

How can one create cyclic (and immutable) data structures in Clojure without extra indirection?

江枫思渺然 提交于 2019-12-03 00:25:38
I need to represent directed graphs in Clojure. I'd like to represent each node in the graph as an object (probably a record) that includes a field called :edges that is a collection of the nodes that are directly reachable from the current node. Hopefully it goes without saying, but I would like these graphs to be immutable. I can construct directed acyclic graphs with this approach as long as I do a topological sort and build each graph "from the leaves up". This approach doesn't work for cyclic graphs, however. The one workaround I can think of is to have a separate collection (probably a

Best Way to Store/Access a Directed Graph

 ̄綄美尐妖づ 提交于 2019-12-02 18:28:27
I have around 3500 flood control facilities that I would like to represent as a network to determine flow paths (essentially a directed graph). I'm currently using SqlServer and a CTE to recursively examine all the nodes and their upstream components and this works as long as the upstream path doesn't fork alot. However, some queries take exponentially longer than others even when they are not much farther physically down the path (i.e. two or three segments "downstream") because of the added upstream complexity; in some cases I've let it go over ten minutes before killing the query. I'm using

Algorithm for topological sorting if cycles exist

北城余情 提交于 2019-12-02 18:27:45
Some programming languages (like haskell ) allow cyclic dependencies between modules. Since the compiler needs to know all definitions of all modules imported while compiling one module, it usually has to do some extra work if some modules import each other mutually or any other kind of cycle occurs. In that case, the compiler may not be able to optimize code as much as in modules that have no import cycles, since imported functions may have not yet been analyzed. Usually only one module of a cycle has to be compiled that way, as a binary object has no dependecies. Let's call such a module

What options are available for the layout of directed or undirected graphs in .NET?

丶灬走出姿态 提交于 2019-12-02 16:45:37
By graph here I mean something resembling these images: The ideal solution would: use only managed code allow output to a bitmap image allow output to WPF elements include some kind of interactive surface for displaying the graph that supports zooming, panning and reorganisation of nodes I'm also interested in hearing about projects that could potentially be used as the starting point for this kind of work. If it requires some development to achieve what I want, then I'm prepared to tackle it. The most complex portion of this goal seems to be obtaining the graph layout in a reasonable time

d3.js collapsible force layout with all the nodes collapsed

我怕爱的太早我们不能终老 提交于 2019-12-02 11:16:29
I've been trying to implement a directed force layout using a json file that I've written. Before I tried to make it begin with all nodes collapsed, it was working properly. I've declared a property called "index" for all the nodes, indicating which level of the tree they belong (root's index is 0, it's children are 1, etc.) I'm guessing that there is a problem with "index" property of the nodes because when I first start my page their values are correct, but when I collapse and re-open one a node the index values of related nodes change and it does not draw the links properly anymore. Any

Design an algorithm for the single source shortest path problem that runs in time O(k(|V|+|E|))

五迷三道 提交于 2019-12-01 21:16:56
Suppose we are given a directed graph G = (V, E) with potentially positive and negative edge lengths, but no negative cycles. Let s ∈ V be a given source vertex. How to design an algorithm for the single-source shortest path problem that runs in time O(k(|V | + |E|)) if the shortest paths from s to any other vertex takes at most k edges ? Here`s O(k(|V | + |E|)) approach: We can use Bellman-Ford algorithm with some modifications Create array D[] to store shortest path from node s to some node u initially D[s]=0, and all other D[i]=+oo (infinity) Now after we iterate throught all edges k times

networkx DiGraph Attribute Error self._succ

给你一囗甜甜゛ 提交于 2019-12-01 11:32:48
Context : I'm trying to run another researcher's code - it describes a traffic model for the Bay Area road network, which is subject to seismic hazard. I'm new to Python and therefore would really appreciate some help debugging the following error. Issue : When I try to run the code for the sample data provided with the file, following the instructions in the README, I get the following error. DN0a226926:quick_traffic_model gitanjali$ python mahmodel_road_only.py You are considering 2 ground-motion intensity maps. You are considering 1743 different site locations. You are considering 2

Shortest path in “two-graph” with limited number of changes

对着背影说爱祢 提交于 2019-12-01 11:05:52
问题 Let's say we have two directed and positive-weighted graphs on one set of vertices (first graph represents for example rail-roads and the second one - bus lanes; vertices are bus stops or rail-road stations or both). We need to find the shortest path from A to B, but we can't change the type of transport more than N times. I was trying to modify the Dijkstra's algorithm, but it's working only on a few "not-so-mean-and-complicated" graphs and I think I need to try something different. How to