graph-algorithm

python graph-tool access vertex properties

倖福魔咒の 提交于 2019-12-06 04:13:21
For my current project I want to use the graph-tool library since they claim being the fastest: https://graph-tool.skewed.de/performance . I have some algorithms (shortest path, etc.) to run on really large networks, so the faster the better! First question: Is this claim 'being the fastest' true? ;) While trying to build a graph-tool graph fitting my needs, I figured out that its not possible to access vertex properties in a efficient way. Maybe I missed something? My question is now, can the function "getVertexFromGraph(graph, position)" be written in a more efficient way? Or more in general

Surface reconstruction from 2 planar contours [closed]

て烟熏妆下的殇ゞ 提交于 2019-12-06 03:36:12
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . There is a class of algorithms for triangulation between two planar contours. These algorithms try to make a "good triangulation" to fill a space between these contours: One of them (Optimal surface reconstruction from planar contours) is based on the dynamic programming

box stacking in graph theory

笑着哭i 提交于 2019-12-06 03:19:41
问题 Please help me find a good solution for this problem. We have n boxes with 3 dimensions. We can orient them and we want to put them on top of another to have a maximun height. We can put a box on top of an other box, if 2 dimensions (width and lenght) are lower than the dimensions of the box below. For exapmle we have 3 dimensions w*D*h, we can show it in to (h*d,d*h,w*d,d*W,h*w,w*h) please help me to solve it in graph theory. in this problem we can not put(2*3)above(2*4) because it has the

graph algorithms: reachability from adjacency map

情到浓时终转凉″ 提交于 2019-12-05 22:21:24
I have a dependency graph that I have represented as a Map<Node, Collection<Node>> (in Java-speak, or f(Node n) -> Collection[Node] as a function; this is a mapping from a given node n to a collection of nodes that depend on n ). The graph is potentially cyclic*. Given a list badlist of nodes, I would like to solve a reachability problem : i.e. generate a Map<Node, Set<Node>> badmap that represents a mapping from each node N in the list badlist to a set of nodes which includes N or other node that transitively depends on it. Example: (x -> y means node y depends on node x) n1 -> n2 n2 -> n3 n3

Algorithm like Bellman-Ford, only for multiple start, single destination?

江枫思渺然 提交于 2019-12-05 14:46:15
Algorithms like the Bellman-Ford algorithm and Dijkstra's algorithm exist to find the shortest path from a single starting vertex on a graph to every other vertex. However, in the program I'm writing, the starting vertex changes a lot more often than the destination vertex does. What algorithm is there that does the reverse--that is, given a single destination vertex, to find the shortest path from every starting vertex? Just reverse all the edges, and treated destination as start node. Problem solved. If this is an undirected graph: I think inverting the problem would give you advantages.

Dijkstras Algorithm doesn't appear to work, my understanding must be flawed

岁酱吖の 提交于 2019-12-05 10:50:14
Here's my interpretation of how Dijkstra's algorithm as described by wikipedia would deal with the below graph. First it marks the shortest distance to all neighbouring nodes, so A gets 1 and C gets 7. Then it picks the neighbour with the current shortest path. This is A. The origin is marked as visited and will not be considered again. The shortest (and only) path from the origin to B through A is now 12. A is marked as visited. The shortest path from the origin to the Destination through B is 13. B is marked as visited. The shortest path from the Origin to C through the destination is 14,

Find the maximally intersecting subset of ranges

青春壹個敷衍的年華 提交于 2019-12-05 07:50:14
If you have a set of ranges, such as the following simple example... [ [12, 25], #1 [14, 27], #2 [15, 22], #3 [17, 21], #4 [20, 65], #5 [62, 70], #6 [64, 80] #7 ] ... how do you compute the maximally intersecting subset (not sure quite how to phrase it, but I mean "the subset of ranges which intersects and has the highest cardinality") and determine the degree of intersection (cardinality of ranges in that subset)? Logically I can work it out, and might be able to translate that to a naive algorithm. Going down the list, we see that 1-5 intersect, and 5-7 intersect, and that #5 intersects both

Algorithm to clone a graph

大兔子大兔子 提交于 2019-12-05 03:43:10
Algorithm to clone a tree is quite easy, we can do pre-order traversal for that. Is there an efficient algorithm to clone a graph? I tried a similar approach, and concluded we need to maintain a hash-map of nodes already added in the new graph, else there will be duplication of nodes, since one node can have many parents. It suffices to do a depth first search and copy each node as it's visited. As you say, you need some way of mapping nodes in the original graph to corresponding copies so that copies of cycle and cross edges can be connected correctly. This map also suffices to remember nodes

Number of unique sequences of 3 digits (-1,0,1) given a length that matches a sum

ⅰ亾dé卋堺 提交于 2019-12-05 02:34:43
问题 Say you have a vertical game board of length n (being the number of spaces). And you have a three-sided die that has the options: go forward one, stay and go back one. If you go below or above the number of board game spaces it is an invalid game. The only valid move once you reach the end of the board is "stay". Given an exact number of die rolls t, is it possible to algorithmically work out the number of unique dice rolls that result in a winning game? So far I've tried producing a list of

Heuristic function for finding the path using A star

会有一股神秘感。 提交于 2019-12-05 02:11:04
问题 I am trying to find a optimal solution for the following problem The numbers denoted inside each node are represented as (x,y) . The adjacent nodes to a node always have a y value that is (current nodes y value +1). There is a cost of 1 for a change in the x value when we go from one node to its adjacent There is no cost for going from node to its adjacent, if there is no change in the value of x . No 2 nodes with the same y value are considered adjacent. The optimal solution is the one with