graph-theory

How to compute the critical path of a directional acyclic graph?

ぃ、小莉子 提交于 2019-12-01 03:05:38
问题 What is the best (regarding performance) way to compute the critical path of a directional acyclic graph when the nodes of the graph have weight? For example, if I have the following structure: Node A (weight 3) / \ Node B (weight 4) Node D (weight 7) / \ Node E (weight 2) Node F (weight 3) The critical path should be A->B->F (total weight: 10) 回答1: I have no clue about "critical paths", but I assume you mean this. Finding the longest path in an acyclic graph with weights is only possible by

Generate a large random planar graph

▼魔方 西西 提交于 2019-12-01 02:51:53
What is the most efficient way to generate a large (~ 300k vertices) random planar graph ("random" here means uniformly distributed)? Another possibility consists in randomly choosing coordinates and then compute a Delaunay Triangulation, which is a planar graph (and looks nice as well). See http://en.wikipedia.org/wiki/Delaunay_triangulation There are O(n log(n)) algorithms to compute such a triangulation. Without any other requirements, I'd say look up random maze generation. If you want cycles in the graph, remove some walls at random from a simple maze. The intersections in the maze become

Non-cycle path to all nodes

感情迁移 提交于 2019-12-01 02:45:19
问题 Is there an algorithm or set of algorithms that would let you find the shortest walking distance from an arbitrary start node so that every node gets visited in a weight, undirected graph? It's not quite Traveling Salesman, because I don't care if a node is visited more than once. (It doesn't even matter if you make it back to the start -- the walker can end up in some far-off node as long as it was the last one needed to visit all nodes.) It's not quite minimum spanning tree, because it may

Completeness of depth-first search

情到浓时终转凉″ 提交于 2019-12-01 02:22:32
I quote from Artificial Intelligence: A Modern Approach : The properties of depth-first search depend strongly on whether the graph-search or tree-search version is used. The graph-search version, which avoids repeated states and redundant paths, is complete in finite state spaces because it will eventually expand every node. The tree-search version, on the other hand, is not complete [...]. Depth-first tree search can be modified at no extra memory cost so that it checks new states against those on the path from the root to the current node; this avoids infinite loops in finite state spaces

A tree, where each node could have multiple parents

牧云@^-^@ 提交于 2019-12-01 00:06:50
问题 Here's a theoretical/pedantic question: imagine properties where each one could be owned by multiple others. Furthermore, from one iteration of ownership to the next, two neighboring owners could decide to partly combine ownership. For example: territory 1, t=0: a,b,c,d territory 2, t=0: e,f,g,h territory 1, t=1: a,b,g,h territory 2, t=1: g,h That is to say, c and d no longer own property; and g and h became fat cats, so to speak. I'm currently representing this data structure as a tree where

Connected Component Labeling in C++

…衆ロ難τιáo~ 提交于 2019-11-30 23:08:45
I need to use the connected component labeling algorithm on an image in a C++ application. I can implement that myself, but I was trying to use Boost's union-find/disjoint sets implementation since it was mentioned in the union-find wiki article. I can't figure out how to create the disjoint_sets object so that it'll work with the image data I have (unsigned shorts). What am I missing? The examples in the Boost documentation aren't making any sense to me. Do I need all the extra Graph mumbo-jumbo in those examples when I have an image? OR, is there already an OpenCV connected component

Suggestions for KSPA on undirected graph

依然范特西╮ 提交于 2019-11-30 22:15:03
There is a custom implementation of KSPA which needs to be re-written. The current implementation uses a modified Dijkstra's algorithm whose pseudocode is roughly explained below. It is commonly known as KSPA using edge-deletion strategy i think so. (i am a novice in graph-theory). Step:-1. Calculate the shortest path between any given pair of nodes using the Dijkstra algorithm. k = 0 here. Step:-2. Set k = 1 Step:-3. Extract all the edges from all the ‘k-1’ shortest path trees. Add the same to a linked list Edge_List. Step:-4. Create a combination of ‘k’ edges from Edge_List to be deleted at

Generate a large random planar graph

拥有回忆 提交于 2019-11-30 21:50:55
问题 What is the most efficient way to generate a large (~ 300k vertices) random planar graph ("random" here means uniformly distributed)? 回答1: Another possibility consists in randomly choosing coordinates and then compute a Delaunay Triangulation, which is a planar graph (and looks nice as well). See http://en.wikipedia.org/wiki/Delaunay_triangulation There are O(n log(n)) algorithms to compute such a triangulation. 回答2: Have you looked at Boltzmann sampling? See the paper by Eric Fusy "Uniform

How to graph adjacency matrix using MATLAB

我的未来我决定 提交于 2019-11-30 19:54:32
I want to create a plot showing connections between nodes from an adjacency matrix like the one below. gplot seems like the best tool for this. However, in order to use it, I need to pass the coordinate of each node. The problem is that I don't know where the coordinates should be, I was hoping the function would be capable of figuring out a good layout for me. For example here's my output using the following arbitrary coordinates: A = [1 1 0 0 1 0; 1 0 1 0 1 0; 0 1 0 1 0 0; 0 0 1 0 1 1; 1 1 0 1 0 0; 0 0 0 1 0 0]; crd = [0 1; 1 1; 2 1; 0 2; 1 2; 2 2]; gplot (A, crd, "o-"); Which is hard to

Facebook Graph Search: Information Retrieval Algorithm

不问归期 提交于 2019-11-30 19:07:38
问题 There is a closed question titled "How does Facebook Graph Search work?" In simplest terms, the OP asked (and even gave a sample of what he tried): How does Facebook Graph Search works? He gave an example: Friends from France who likes England How can the above be implemented as a real world Information Retrieval problem? As my answer was not fitting in the comment so thought of re-framing the question and answering it well in Stack Overflow Q&A style. 回答1: From an implementation perspective