graph-theory

Finding a Minimum Spanning Tree given the old MST and a new vertex + edges

天涯浪子 提交于 2019-12-06 11:38:18
问题 In a sample problem, I'm given a MST T for a weighted graph G = (V, E). The question is, if a new vertex v and all its edges are to be added to the graph, what is an o(|V|log|V|) algorithm to compute the new MST of this new G* = (V U v, E*). My only idea so far is: add min( out(v) ) to T for each edge e in out(v) do let u be the other vertex of e if there exists a lower weight path from v to u then remove all edges in that path from T add e to T Two problems: What do I do with the vertices

Dijkstra's Algorithm Does not generate Shortest Path?

橙三吉。 提交于 2019-12-06 10:29:41
问题 I am working through a shortest path problem using Dijkstra's Algorithm. I am having trouble because the algorithm is supposed to provide the shortest path, but after running the algorithm I get a shorted path by hand. Is this just a by-product of this algorithm? The path I am trying to generate is from a -> z Here is the path that I get from applying the algorithm, taking the shortest distance jump at each vertex I visit: 2 4 2 2 1 2 1 1 8 = 23 a -> d -> g -> k -> r -> n -> q -> p -> t -> z

Visit all nodes in a graph with least repeat visits

孤街浪徒 提交于 2019-12-06 10:13:40
I have a tile based map where several tiles are walls and others are walkable. the walkable tiles make up a graph I would like to use in path planning. My question is are their any good algorithms for finding a path which visits every node in the graph, minimising repeat visits? For example: map example http://img220.imageshack.us/img220/3488/mapq.png If the bottom yellow tile is the starting point, the best path to visit all tiles with least repeats is: path example http://img222.imageshack.us/img222/7773/mapd.png There are two repeat visits in this path. A worse path would be to take a left

Find a line passing the maximum number of points [closed]

被刻印的时光 ゝ 提交于 2019-12-06 07:48:27
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I found a Google Interview question on CareerCup Given a 2D plane, suppose that there are around 6000 points on it. Find a line which

Java library for graphs

眉间皱痕 提交于 2019-12-06 06:37:53
问题 what is the best Java library for manipulating graphs (specifically, for social network analysis)? I've seen Jung, but I was wondering if you knew anything better (I don't need to visualize networks, only computation). Thank you 回答1: I've found jgrapht pretty useful - it has all the major algorithms (e.g. Bellman-Ford, ...) 回答2: neo4j is the choice And here is a video 回答3: If you are aiming for high efficiency http://grph.inria.fr/ 来源: https://stackoverflow.com/questions/4362219/java-library

What if I do not use G transpose in calculating Strongly Connected Components?

不问归期 提交于 2019-12-06 04:47:22
I am reading Introduction to Algorithms. In 22.5 Strongly Connected Component, the algorithm STRONGLY-CONNECTED-COMPONENT(G) is defined as: Call DFS(G) to compute finishing times u.f for each vertex u Compute G transpose Call DFS(G transpose), but in the main loop of DFS, consider the vertices in order of decreasing u.f(as computed in line 1) Output the vertices of each tree in the depth-first forest formed in line 3 as a separate strongly connected component If I change the alogrithm to just using G, without calculating G transpose. Also consider the vertices in order of Increasing u.f

Probability to visit nodes in a random walk on graph

拥有回忆 提交于 2019-12-06 03:32:03
问题 I have a finite undirected graph in which a node is marked as "start" and another is marked as "goal". An agent is initially placed at the start node and it navigates through the graph randomly, i.e. at each step it chooses uniformly at random a neighbor node and moves to it. When it reaches the goal node it stops. I am looking for an algorithm that, for each node, gives an indication about the probability that the agent visits it, while traveling from start to goal. Thank you. 回答1: As is

Can I choose a random element from a set if I don't know the size of the set?

点点圈 提交于 2019-12-06 03:06:46
I'm writing a bit of JavaScript code which should select a random item from a canvas if the item meets certain requirements. There are different kinds of items (circles, triangles, squares etc.) and there's usually not the same number of items for each kind. The items are arranged in a hierarchy (so a square can contain a few circles, and a circle can contain other circles and so on - they can all be nested). Right now, my (primitive) approach at selecting a random item is to: Recursively traverse the canvas and build a (possibly huge!) list of items Shuffle the list Iterate the shuffled list

OrientDB GraphED - SQL insert edge between two (select vertex RID)s? Or alternative approach for very large import

杀马特。学长 韩版系。学妹 提交于 2019-12-06 01:37:34
For example, two simple vertices in an OrientDB Graph: orientdb> CREATE DATABASE local:/databases/test admin admin local graph; Creating database [local:/databases/test] using the storage type [local]... Database created successfully. Current database is: local:/graph1/databases/test orientdb> INSERT INTO V (label,in,out) VALUES ('vertexOne',[],[]); Inserted record 'V#6:0{label:vertexOne,in:[0],out:[0]} v0' in 0.001000 sec(s). orientdb> INSERT INTO V (label,in,out) VALUES ('vertexTwo',[],[]); Inserted record 'V#6:1{label:vertexTwo,in:[0],out:[0]} v0' in 0.000000 sec(s). Is there a way to

Sorting Geographical non-contiguous line segments along an implied curve

邮差的信 提交于 2019-12-06 01:27:31
Given: A Set (for the sake of discussion we will call it S ), which is an unordered collection of line segments. Each line segment is defined as two Longitude-Latitude end-points. While all of the line segments follow an implied curve, there are "gaps" between each of the segments, of various sizes. We refer to this curve as "implied" because it is not explicitly defined anywhere. The only information that we have available are the line segments contained within S . Desired Result: A sequence (for the sake of discussion we will call it R ), which is an ordered collection of line segments. Each