graph-theory

GPU-based search for all possible paths between two nodes on a graph

牧云@^-^@ 提交于 2021-02-07 17:23:31
问题 My work makes extensive use of the algorithm by Migliore, Martorana and Sciortino for finding all possible simple paths, i.e. ones in which no node is encountered more than once, in a graph as described in: An Algorithm to find All Paths between Two Nodes in a Graph. (Although this algorithm is essentially a depth-first search and intuitively recursive in nature, the authors also present a non-recursive, stack-based implementation.) I'd like to know if such an algorithm can be implemented on

Algorithm to traverse all edges in a graph

試著忘記壹切 提交于 2021-02-07 13:20:35
问题 As a personal easter project I'm trying to implement some model-based testing at work. I've got a graph implemented in python and I need to traverse all edges / do all transitions of the graph, at least once. Traversing an edge twice or more does not matter, but I need to start and end in the same node and get a sequence of edges/transitions back. Simpler algorithm > shortest sequence. I've looked around and found a lot of algorithms, but I couldn't find one / a combination that works for me.

Partitioning a colored grid

爷,独闯天下 提交于 2021-02-07 04:11:52
问题 I want to gerrymander a grid. What this means is that given an n x m grid with squares colored yellow and red, I want to partition the grid in such a way that yellow will be the majority color in as many partions as possible, as in this image: All partitions must be continuous, the same number of squares, and all squares will be colored (although it would be awesome if an algorithm could generalize to grids with some squares not colored). I'm not sure how to even go about 'algorithmitizing'

What algorithm can I use to find the shortest path between specified node types in a graph?

一个人想着一个人 提交于 2021-02-06 19:56:45
问题 This is the problem: I have n points (p1, p2, p3, .. pn), each of them can connect to any other with a determined cost x. Each point belongs to one of a set of point-types (for example "A" "B" "C" "D"...). The input of the method is the path I want to follow, for example "A-B-C-A-D-B". The output is the shortest path connecting the points of the type I give in input so for example "p1-p4-p32-p83-p43-p12" where p1 is an A-type, p4 a B-type, p32 a C-type, p83 an A-type, p43 a D-type and p12 a B

How to find Strongly Connected Components in a Graph?

人盡茶涼 提交于 2021-02-05 20:20:17
问题 I am trying self-study Graph Theory, and now trying to understand how to find SCC in a graph. I have read several different questions/answers on SO (e.g., 1,2,3,4,5,6,7,8), but I cant find one with a complete step-by-step example I could follow. According to CORMEN (Introduction to Algorithms), one method is: Call DFS(G) to compute finishing times f[u] for each vertex u Compute Transpose(G) Call DFS(Transpose(G)), but in the main loop of DFS, consider the vertices in order of decreasing f[u]

How to find Strongly Connected Components in a Graph?

心不动则不痛 提交于 2021-02-05 20:11:00
问题 I am trying self-study Graph Theory, and now trying to understand how to find SCC in a graph. I have read several different questions/answers on SO (e.g., 1,2,3,4,5,6,7,8), but I cant find one with a complete step-by-step example I could follow. According to CORMEN (Introduction to Algorithms), one method is: Call DFS(G) to compute finishing times f[u] for each vertex u Compute Transpose(G) Call DFS(Transpose(G)), but in the main loop of DFS, consider the vertices in order of decreasing f[u]

Graphs: find a sink in less than O(|V|) - or show it can't be done

耗尽温柔 提交于 2021-02-05 18:57:44
问题 I have a graph with n nodes as an adjacency matrix . Is it possible to detect a sink in less than O(n) time? If yes, how? If no, how do we prove it? Sink vertex is a vertex that has incoming edges from other nodes and no outgoing edges. 回答1: Suppose to the contrary that there exists an algorithm that queries fewer than (n-2)/2 edges, and let the adversary answer these queries arbitrarily. By the Pigeonhole Principle, there exist (at least) two nodes v, w that are not an endpoint of any edge

Graphs: find a sink in less than O(|V|) - or show it can't be done

限于喜欢 提交于 2021-02-05 18:56:42
问题 I have a graph with n nodes as an adjacency matrix . Is it possible to detect a sink in less than O(n) time? If yes, how? If no, how do we prove it? Sink vertex is a vertex that has incoming edges from other nodes and no outgoing edges. 回答1: Suppose to the contrary that there exists an algorithm that queries fewer than (n-2)/2 edges, and let the adversary answer these queries arbitrarily. By the Pigeonhole Principle, there exist (at least) two nodes v, w that are not an endpoint of any edge

Create a tree structure from a graph

三世轮回 提交于 2021-02-05 06:40:05
问题 I'm trying to find the right approach to graphing a dataset that contains information on amount of time users typically spend in various locations. Importantly, there are categories and subcategories with increasing levels of granularity to my data (for example, 60% of people are at "home", and of those 40% are in the "living room"). I am aware of TreeMaps which would display the information and relationships I need, but I have been asked to make a "network" visualization of the data. What I

Why does my implementation of randomized Prim's Algorithm in Java just generate a full grid?

自作多情 提交于 2021-01-29 17:41:50
问题 I attempted to follow this pseudocode on wikipedia https://en.wikipedia.org/wiki/Maze_generation_algorithmRandomized_Prim's_algorithm but my code just generates a full grid. I seem to be missing something in my understanding of what the algorithm does. Can someone help explain what I'm doing wrong? I've looked at a few sources but I can't wrap my head around it public class MazeGen { private int dimension, nodeCounter; private Node[][] nodes; private List<Edge> walls; public static void main