directed-graph

Algorithm to check if directed graph is strongly connected

给你一囗甜甜゛ 提交于 2019-11-30 03:41:13
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? 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. Both are linear time. As with a normal depth first search, you track the status of each node: new, seen but

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

回眸只為那壹抹淺笑 提交于 2019-11-29 21:15:02
问题 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++

Implementing a node-based graphical interface?

橙三吉。 提交于 2019-11-29 19:59:37
I would like to implement a nodal-interface, basically a DAG where each node performs an operation on it's input connections, and outputs something (which you can connect to another node) Some example applications: Apples "Shake" - screenshot The Foundrys "Nuke" - screenshot MindNode - screenshot vvvv - screenshots Quartz Composer - screenshot As a first goal, I would like to have an graphical application with only 2 nodes. A "number" which simply outputs a fixed number, and an "Add" node, which takes two inputs and outputs the sum of the two. As people have answered so-far, I have a rough

MySQL Store Relationship (Family) Tree

房东的猫 提交于 2019-11-29 15:25:25
问题 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

Topological sort of cyclic graph with minimum number of violated edges

本秂侑毒 提交于 2019-11-29 07:11:00
问题 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? 回答1:

Tarjan cycle detection help C#

北城余情 提交于 2019-11-29 01:38:06
问题 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

Graph serialization

∥☆過路亽.° 提交于 2019-11-28 17:25:59
I'm looking for a simple algorithm to 'serialize' a directed graph. In particular I've got a set of files with interdependencies on their execution order, and I want to find the correct order at compile time. I know it must be a fairly common thing to do - compilers do it all the time - but my google-fu has been weak today. What's the 'go-to' algorithm for this? Andrew Peters Topological Sort (From Wikipedia): In graph theory, a topological sort or topological ordering of a directed acyclic graph (DAG) is a linear ordering of its nodes in which each node comes before all nodes to which it has

Implementing a node-based graphical interface?

时间秒杀一切 提交于 2019-11-28 16:04:42
问题 I would like to implement a nodal-interface, basically a DAG where each node performs an operation on it's input connections, and outputs something (which you can connect to another node) Some example applications: Apples "Shake" - screenshot The Foundrys "Nuke" - screenshot MindNode - screenshot vvvv - screenshots Quartz Composer - screenshot As a first goal, I would like to have an graphical application with only 2 nodes. A "number" which simply outputs a fixed number, and an "Add" node,

Collapsible D3 force directed graph with non-tree data

半腔热情 提交于 2019-11-28 06:05:14
问题 I have a D3 force directed graph using non-tree data and ID associations vs index. I cannot seem to find an example of this structure of data in a collapsible force layout. Basically, when you click a node, the data for that node should collapse/expand like this example: http://bl.ocks.org/mbostock/1062288. The last answer to this questions got close but is linking nodes by index rather than id: How to create d3.js Collapsible force layout with non tree data? Here is a fiddle of my code https

Find all cycles in a graph implementation

折月煮酒 提交于 2019-11-28 06:04:46
问题 I have found a simple algorithm to find all cycles in a graph here. I need to print out the cycles too, is it possible with this algorithm. Please find the code below. I'm getting the number of cycles correctly! node1, node2 are integers. visited is a dictionary def dfs(self,node1, node2): if self.visited[node2]: if(node1 == node2): self.count += 1 print node2 return self.visited[node2] = True for x in self.adj_lst[node2-1]: self.dfs(node1, x) self.visited[node2] = False def allCycles(self):