0

My English is not very well, BUT I will try my best to explain my issue here. I am working on an application in which I have to create graph. For now I am using GraphStream.

Requirements for my graph is very complicated, which is :

I have a table named CDR(Call Data Record) in which I have 2 columns ANUMBER and BNUMBER. The structure of table is very clear that it shows that Anumber called Bnumber and there is another column for DATETIME, which shows the date and time of call. BUT I need here only two columns.

Lets say we have 4 numbers here : 123, 456 ,789 ,000 and table structure is like this

Anumber    Bnumber
-------    -------
123        456
123        789
456        789
789        000
456        000

My table here clearly shows that 123 didn't call 000 But 123 called 456 and 789 and these two numbers called 000 So I have to show the directed graph between 123 and 000 which probably shows like this 123->456->000 and 132->789->000

So the issue is I don't know how to find this path between 123 and 000. There may be more than 2 numbers like 5 or 6 numbers and I have to find the hidden numbers between all the given 5 or 6 numbers AS in the above scenario 456 and 789 are hidden numbers between 132 and 000.

And one thing more my table contains more than 20 million rows and in future obviously the number of rows will grow very fast as user calls each other.

WHAT I HAVE DONE SO FAR:

I have done some R&D on this issue but couldn't found any good library or any solution for this. So far, I think Dijkstra's Algorithm is best for my scenario as GraphStream luckily provides this algorithm here.

What I want from you guys, Give me an idea that Will this algorithm will give me required result OR I have to find any other algo or graph library which will suits best for my problem. I am not good at ALGO's thats why I am here for any help or guideline If you guys can gave me. Thanks

James Z
  • 12,209
  • 10
  • 24
  • 44
Noob Player
  • 279
  • 6
  • 25
  • In the webpage you link, it says that there's a few methods to iterate over the shortest path. (getPathEdges(Node), getPathEdgesIterator(Node), getPathNodes(Node) and getPathNodesIterator(Node)). I believe that getPathEdges(Node) and getPathNodes(Node) give you the information you want. Try to use them and comment if they do the work. – Shinra tensei Jul 20 '17 at 10:26
  • Sure. I will try it and if it comes according to my needs I will post my solution here – Noob Player Jul 20 '17 at 10:28
  • Still, I'd recommend you to understand and implement Dijkstra's algorithm by yourself. It's not hard to understand and that way you'll be able to modify it for anything you could want it to do. – Shinra tensei Jul 20 '17 at 10:31
  • Yes, I will try my best to do it on my own. I just needed the confirmation about Dijkstra's algorithm that it will give me the required results – Noob Player Jul 20 '17 at 10:37

1 Answers1

0

You don't need Dijkstra's algorithm at all, since you don't have costs on edges. You need simple BFS algorithm. Here is simple implementation but you should add 'labels' array to mark visited nodes. So after BFS you can restore pass from each node to source node(123 in your case) or say that node cannot be reached from given node(if label for this node remains 0). You should add label in the following way:

all labels equals 0 on start

when you visit new node you set it's label as current_node_label+1

But Dijkstra's can help you if you set cost of each edge as 1. It's just not efficient way to sole you problem.