graph-theory

An interesting graph task

给你一囗甜甜゛ 提交于 2019-11-30 18:32:36
问题 There is a tree with n vertices. We are asked to calculate minimum size of a multiset S such for each edge (u,v) in the tree at least one of the following holds: u ∈ S v ∈ S there are at least two vertices in S, each of which is adjacent to u or v. Since S is a multiset, a vertex may be in S multiple times. My hunch is the following. First of all, we take into consideration the following fact: in optimal solution each vertex is in S at most twice. So we can traverse tree in post-order

Connected Component Labeling in C++

倾然丶 夕夏残阳落幕 提交于 2019-11-30 17:53:21
问题 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

Calculate shortest path through a grocery store

℡╲_俬逩灬. 提交于 2019-11-30 14:50:04
问题 I'm trying to find a way to find the shortest path through a grocery store, visiting a list of locations (shopping list). The path should start at a specified start position and can end at multiple end positions (there are multiple checkout counters). Also, I have some predefined constraints on the path, such as "item x on the shopping list needs to be the last, second last, or third last item on the path". There is a function that will return true or false for a given path. Finally, this

Efficently simulate rolling weighted dice (or traversing a weighted graph), with frequent updates

橙三吉。 提交于 2019-11-30 14:35:34
I have a weighted, directed graph which is dense with around 20,000 nodes. Given an node in the graph, I choose an adjacent node randomly with a probability related to the relative weights. After each choice, I receive feedback about whether the choice was good or bad, and update the network. For example, after a bad choice I decrease the weight of all edges pointing to the chosen node. I learned yesterday about the alias method for simulating rolling a weighted die, which is the same as making one choice (each node is one weighted die, and the sides correspond to other nodes). One roll is

Any working example of VF2 algorithm?

喜你入骨 提交于 2019-11-30 14:11:33
问题 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

What is the meaning of “from distinct vertex chains” in this nearest neighbor algorithm?

自古美人都是妖i 提交于 2019-11-30 13:11:09
问题 The following pseudo-code is from the first chapter of an online preview version of The Algorithm Design Manual (page 7 from this PDF). The example is of a flawed algorithm, but I still really want to understand it: [...] A different idea might be to repeatedly connect the closest pair of endpoints whose connection will not create a problem, such as premature termination of the cycle. Each vertex begins as its own single vertex chain. After merging everything together, we will end up with a

Topological Sort with Grouping

旧街凉风 提交于 2019-11-30 13:09:21
Ok, so in topological sorting depending on the input data, there's usually multiple correct solutions for which order the graph can be "processed" so that all dependencies come before nodes that are "dependent" on them. However, I'm looking for a slightly different answer: Suppose the following data: a -> b and c -> d ( a must come before b and c must come before d ). With just these two constraints we have multiple candidate solutions: ( a b c d , a c d b , c a b d , etc). However, I'm looking to create a method of "grouping" these nodes so that after the processing of a group, all of the

Calculate shortest path through a grocery store

谁说胖子不能爱 提交于 2019-11-30 11:32:00
I'm trying to find a way to find the shortest path through a grocery store, visiting a list of locations (shopping list). The path should start at a specified start position and can end at multiple end positions (there are multiple checkout counters). Also, I have some predefined constraints on the path, such as "item x on the shopping list needs to be the last, second last, or third last item on the path". There is a function that will return true or false for a given path. Finally, this needs to be calculated with limited CPU power (on a smartphone) and within a second or so. If this isn't

Algorithm for Finding Redundant Edges in a Graph or Tree

有些话、适合烂在心里 提交于 2019-11-30 11:28:13
问题 Is there an established algorithm for finding redundant edges in a graph? For example, I'd like to find that a->d and a->e are redundant, and then get rid of them, like this: => Edit: Strilanc was nice enough to read my mind for me. "Redundant" was too strong of a word, since in the example above, neither a->b or a->c is considered redundant, but a->d is. 回答1: You want to compute the smallest graph which maintains vertex reachability. This is called the transitive reduction of a graph. The

Designing a Yahoo Pipes inspired interface [closed]

拥有回忆 提交于 2019-11-30 11:06:35
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 12 months ago . I really like the interface for Yahoo Pipes (http://pipes.yahoo.com/pipes/) and would like to create a similar interface for a different problem. Are there any libraries that would allow me to create an interface with the same basic look and feel? I especially like how the pipes behave and how they are not