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 8 years ago.
Improve this question
We know that we can use adjacency list or adjacency matrix for algorithm on graph. It is pretty easy and straightforward for small graphs. But when the graph is very big, for example social network graph, what data structure should be best for implementing traditional algorithms like shortest path finding. Adjacency matrix or list won't work because of high memory requirements, right? What approach do social network engines use?
Adjacency lists are in use in the sources I have found. For very large data sizes you might end up either holding the data on disk or using multiple machines to solve the problem - so I suggest adding keywords such as "external memory" or Hadoop to the search. I tried adding Hadoop and found some papers on solving single source shortest path via parallel breadth first search - http://www.cs.kent.edu/~jin/Cloud12Spring/GraphAlgorithms.pptx, http://courses.cs.washington.edu/courses/cse490h/08au/lectures/algorithms.pdf, Hadoop MapReduce implementation of shortest PATH in a graph, not just the distance
In addition, http://researcher.watson.ibm.com/researcher/files/us-heq/Large%20Scale%20Graph%20Processing%20with%20Apache%20Giraph.pdf does not cover shortest path but is an interesting example of solving connected components using a layer on top of Hadoop that may make life easier.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
So, I have been doing research about solving the Game Strategy problem of ICPC 2014 (page 7).
This consist in a board game with n boxes, each box have a unique set of paths that goes to another box on the board (can have a path that goes to itself). I think a graph would be a good representation of the game, more specific a directed graph
graphic case representation whit n = 2
I found 2 possible algorithms that should solve the problem:
1.- A YouTube video where it says that i should use the Breadth-first search
2.- Blog commenting the solution of some of the problems of that ICPC year. The author says that DP (dynamic programming) can be used. In Wikipedia's page is explained an algorithm called Dijkstra's algorithm which is used for "the shortest path problem" as the page says.
Is one of these algorithms an better solution for the problem? does one of those have better performance or something like that?
You use Breadth-first search (shortyly BFS) when the graph's edges are without weight (as your case) and Dijkstra's algorithm for weighted graph.
As a side note, remember that Dijkstra doesn't work when you have edges with negative values.
Thinking of complexity, this question might be in your interest: Why use Dijkstra's Algorithm if Breadth First Search (BFS) can do the same thing faster?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I wanna make a graph that force the kruskal algorithm to worst case.
So, lets say that we dont care for sorting the edges time or other operations, but we care only about how we make the edges so that the algorithm makes the most union operations when taking them.
Maybe something like this. Can you give me an example with more nodes, or the idea for how to make the graph?
My idea is, take any graph with more nodes and with less no of cycles.For ex, take a graph with 20 nodes and with one cycle of length 3. In this case, The no of edges we can avoid in MST is only of that contribute cycle. If the graph doesn't contain more cycles we would obviously need many union operations, since most of the vertices belong to different sets.
If you want to have as many union operations as possible, why don't you consider a tree as input instead of a general graph? Simply because in a tree, (trivially) every edge needs to be added to the result set, so with one having n nodes, you will have n − 1 unions.
The edge weights won't matter any more.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Lets assume i have a weighted undirected graph with edges and wanted to find the shortest path as well as all possible paths that i could follow from the startpoint to the endpoint with distances, what would be the best way to implement this? Breadth depth search and k paths algorithm seem to offer reasonable solutions, although im not sure which is best
Sorry, can't post this as comments...
If you need all possible paths, you can't do really better than "tree" traversal (BFS or DFS for instance). Note that you'll need to consider each node as many times as it can be reached from the start (the "tree" is much bigger than the original graph - even infinite if you have cycles in your graph, but let's assume you don't).
To get the smallest path, you could look for it in your list in the end; or preferably, you could use a Dijkstra-like order for your tree traversal, so the shortest path will be the first to come up.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I know there is alot of shortest path Algorithms but i want to ask if there any modifications can be done , to make some Algorithms like a* or Dijkstra chose the shortest path but without the diagonally moves so up and
down and right and left are the allowed moves
The algorithm you probably want is A* (if you want a short path over a large map with some coherent obstacles), though you might just need Dijkstra's (if you must have the mathematically shortest path, or if the map doesn't have any real relation to anything physical). You simply disallow diagonal moves and you might get better results if you use Manhattan distance as your heuristic for A*. For Dijkstra's, the graph has no diagonal links.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm a beginner trying to implement the A* search algorithm for practice and I'm wondering what is the best way of going about it. I have created a graph structure (adjacency matrix) and my plan was to apply the A* to an initial and goal vertex. Also creating the heuristic and improving it as I go along. Question is, can this even work? I have had a look at other implementations and they have done it using different data structures.
That depends on how you implemented the adjacency matrix.
One critical point of A* is finding a node's neighbors. If you implement the matrix as a simple dense bit field, where you have a 1 for adjacent nodes and a 0 for non-adjacent ones, then this search is quite inefficient because you have to check every node. Although inefficient, this does not prevent you from implementing A*.
If you have a more involved implementation of the adjacency matrix, e.g. as a sparse matrix, which allows you to query the neighbors directly, this will be better suited for A*.