directed-graph

How to create d3.js Collapsible force layout with non tree data?

夙愿已清 提交于 2019-12-01 08:00:37
I have a d3 force directed layout with data in a similar structure below. Is it possible to apply collapsible force layout such as http://bl.ocks.org/mbostock/1062288 to it? I want a node to be collapsed /expanded on click. { "nodes": [ {"x": 469, "y": 410}, {"x": 493, "y": 364}, {"x": 442, "y": 365}, {"x": 467, "y": 314}, ], "links": [ {"source": 0, "target": 1}, {"source": 1, "target": 2}, {"source": 2, "target": 0}, {"source": 1, "target": 3}, {"source": 3, "target": 2}, ] } If I understand correctly, perhaps this is what you are looking for. I edited the demo you linked to. Now when a

networkx DiGraph Attribute Error self._succ

耗尽温柔 提交于 2019-12-01 07:28:06
问题 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

How to create d3.js Collapsible force layout with non tree data?

元气小坏坏 提交于 2019-12-01 06:53:34
问题 I have a d3 force directed layout with data in a similar structure below. Is it possible to apply collapsible force layout such as http://bl.ocks.org/mbostock/1062288 to it? I want a node to be collapsed /expanded on click. { "nodes": [ {"x": 469, "y": 410}, {"x": 493, "y": 364}, {"x": 442, "y": 365}, {"x": 467, "y": 314}, ], "links": [ {"source": 0, "target": 1}, {"source": 1, "target": 2}, {"source": 2, "target": 0}, {"source": 1, "target": 3}, {"source": 3, "target": 2}, ] } 回答1: If I

Finding all cycles in a directed graph using recursive backtracking

会有一股神秘感。 提交于 2019-12-01 00:13:55
I am working on finding cycles in directed graph using recursive backtracking. There is a suggested pseudocode for this here , which is here: dfs(adj,node,visited): if (visited[node]): if (node == start): "found a path" return; visited[node]=YES; for child in adj[node]: dfs(adj,child,visited) visited[node]=NO; Call the above function with the start node: visited = {} dfs(adj,start,visited) While this is not the most efficient algorithm when compared to Tarjans algorithm , this is simple enough me for me to understand. Currently, this code does not have a count of number cycles detected. I

Finding all cycles in a directed graph using recursive backtracking

对着背影说爱祢 提交于 2019-11-30 18:34:06
问题 I am working on finding cycles in directed graph using recursive backtracking. There is a suggested pseudocode for this here, which is here: dfs(adj,node,visited): if (visited[node]): if (node == start): "found a path" return; visited[node]=YES; for child in adj[node]: dfs(adj,child,visited) visited[node]=NO; Call the above function with the start node: visited = {} dfs(adj,start,visited) While this is not the most efficient algorithm when compared to Tarjans algorithm , this is simple enough

Is there a library that provides a (directed) hypergraph implementation in C++?

对着背影说爱祢 提交于 2019-11-30 14:57:35
I'm currently working on a project that enumerates the k-best solutions of a dynamic program using a directed hypergraph framework. My current implementation (in Python) works well, but is fairly slow. The algorithm performs a number of tight loops and a fair bit of recursion. I really think that I could realize significant speed improvements using a C++ implementation. However, after a fair bit of searching, I was unable to find any libraries that provide hypergraph implementations in C++ (specifically directed hypergraphs -- but I was unable to find even libraries for undirected hypergraphs)

Algorithm to check if directed graph is strongly connected

喜夏-厌秋 提交于 2019-11-30 12:54:43
问题 I need to check if a directed graph is strongly connected , or, in other words, if all nodes can be reached by any other node (not necessarily through direct edge). One way of doing this is running a DFS and BFS on every node and see all others are still reachable. Is there a better approach to do that? 回答1: Tarjan's strongly connected components algorithm (or Gabow's variation) will of course suffice; if there's only one strongly connected component, then the graph is strongly connected.

MySQL Store Relationship (Family) Tree

柔情痞子 提交于 2019-11-30 10:09:18
I need to build a family tree in php and MySQL. I'm pretty surprised at the lack of open source customizable html family tree-building software there is out there, but I digress. I have spent a lot of time reading about storing MySQL digraphs and family trees. Everything makes sense to me: have a table with nodes (people) and a table with edges (relationships). The only problem I have is I'm not sure of the best way to store relationships that are not necessarily adjacent, for example sibling and grandparent relationships. At first I didn't think this would be a big deal because I can just

Topological sort of cyclic graph with minimum number of violated edges

流过昼夜 提交于 2019-11-30 07:03:06
I am looking for a way to perform a topological sorting on a given directed unweighted graph, that contains cycles. The result should not only contain the ordering of vertices, but also the set of edges, that are violated by the given ordering. This set of edges shall be minimal. As my input graph is potentially large, I cannot use an exponential time algorithm. If it's impossible to compute an optimal solution in polynomial time, what heuristic would be reasonable for the given problem? David Eisenstat Eades, Lin, and Smyth proposed A fast and effective heuristic for the feedback arc set

Tarjan cycle detection help C#

狂风中的少年 提交于 2019-11-30 04:20:16
Here is a working C# implementation of tarjan's cycle detection. The algorithm is found here: http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm public class TarjanCycleDetect { private static List<List<Vertex>> StronglyConnectedComponents; private static Stack<Vertex> S; private static int index; private static DepGraph dg; public static List<List<Vertex>> DetectCycle(DepGraph g) { StronglyConnectedComponents = new List<List<Vertex>>(); index = 0; S = new Stack<Vertex>(); dg = g; foreach (Vertex v in g.vertices) { if (v.index < 0) { strongconnect(v); } } return