graph-theory

Relaxation of an edge in Dijkstra's algorithm

雨燕双飞 提交于 2019-11-30 10:44:56
What does relaxation of an edge mean in the context of graph theory ? I came across this while studying up on Dijkstra's algorithm for single source shortest path. krjampani Here's a nice description of the Algorithm that also explains the notion of relaxation. The notion of "relaxation" comes from an analogy between the estimate of the shortest path and the length of a helical tension spring, which is not designed for compression. Initially, the cost of the shortest path is an overestimate, likened to a stretched out spring. As shorter paths are found, the estimated cost is lowered, and the

Graphs data structure: DFS vs BFS?

前提是你 提交于 2019-11-30 10:17:57
问题 if given a graph problem how do we know whether we need to use bfs or dfs algorithm??? or when do we use dfs algorithm or bfs algorithm. What are the differences and advantages of one over other? 回答1: BFS is going to use more memory depending on the branching factor... however, BFS is a complete algorithm... meaning if you are using it to search for something in the lowest depth possible, BFS will give you the optimal solution. BFS space complexity is O(b^d) ... the branching factor raised to

Hungarian Algorithm and multiple factors

蓝咒 提交于 2019-11-30 10:12:12
I have a situation where I need to allocate people to several events. If we just had a price as a factor, it would be fine, but there is a number of factors that come in. First, some background. This is for a non-profit organization that promotes story hours for children that are hospitalized for any reason, so they depend on voluntary work to do so. So, since they rely on people's good will, they give people as much work as people can / want to do, which varies like: Some people can only do mornings, and some other people can only do afternoons; Some people can only do Mondays, and Thursdays,

Any working example of VF2 algorithm?

核能气质少年 提交于 2019-11-30 09:43:17
I have been reading the VF2 algorithm for finding if two graphs are isomorphic but am somehow missing the big picture. Could be that I am missing the relevant background in this area but all I see is a bunch of rules that I need to use at each step, without seeing an intuitive explanation for why the steps are being carried out. From basic Googling, it appears that this is considered one of the de facto algorithms for finding if two graphs are isomorphic but for some reason I am unable to find an explanation that is simple enough to understand at a high level. Or is this algorithm known by a

Detect rings/circuits of connected voxels

China☆狼群 提交于 2019-11-30 09:38:44
问题 I have a skeletonized voxel structure that looks like this: The actual structure is significantly larger than this exampleIs there any way to find the closed rings in the structure? I tried converting it to a graph and using graph based approaches but they all have the problem that a graph has no spatial information of node position and hence a graph can have multiple rings that are homologous. It is not possible to find all the rings and then filter out the ones of interest since the graph

minimum connected subgraph containing a given set of nodes

。_饼干妹妹 提交于 2019-11-30 08:13:36
I have an unweighted, connected graph. I want to find a connected subgraph that definitely includes a certain set of nodes, and as few extras as possible. How could this be accomplished? Just in case, I'll restate the question using more precise language. Let G(V,E) be an unweighted, undirected, connected graph. Let N be some subset of V. What's the best way to find the smallest connected subgraph G'(V',E') of G(V,E) such that N is a subset of V'? Approximations are fine. I can't think of an efficient algorithm to find the optimal solution, but assuming that your input graph is dense, the

How to assign the same style to a group of edges?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 08:04:57
I've got a graph that I want graphviz to layout and visualize for me. The graph has 122 edges and 123 nodes. The edges are of 4 different kinds and I want them to be visually distinguishable. However I've not yet decided what would be the best way of doing that, I'd like to play around with the dials a bit. Unfortunately I do not see anything like a "class" or "stylesheet" attribute for edges. I can only set visual attributes individually for every edge (lots of repetition). Perhaps I've missed something? Is there maybe some way after all to add edges to 4 different groups and then style the

Touching segments

你。 提交于 2019-11-30 07:32:14
Can anyone please suggest me algorithm for this. You are given starting and the ending points of N segments over the x-axis. How many of these segments can be touched, even on their edges, by exactly two lines perpendicular to them? Sample Input : 3 5 2 3 1 3 1 5 3 4 4 5 5 1 2 1 3 2 3 1 4 1 5 3 1 2 3 4 5 6 Sample Output : Case 1: 5 Case 2: 5 Case 3: 2 Explanation : Case 1: We will draw two lines (parallel to Y-axis) crossing X-axis at point 2 and 4. These two lines will touch all the five segments. Case 2: We can touch all the points even with one line crossing X-axis at 2. Case 3: It is not

How can I order a list of connections

ぃ、小莉子 提交于 2019-11-30 07:13:41
问题 I currently have a list of connections stored in a list where each connection is a directed link that connects two points and no point ever links to more than one point or is linked to by more than one point. For example: connections = [ (3, 7), (6, 5), (4, 6), (5, 3), (7, 8), (1, 2), (2, 1) ] Should produce: ordered = [ [ 4, 6, 5, 3, 7, 8 ], [ 1, 2, 1 ] ] I have attempt to do this using an algorithm that takes an input point and a list of connections and recursively calls itself to find the

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