I have following Graph Text file, It is big file I want to convert into adjacency List in scala. First few lines of the text file given below:
src, dst,dist
A,C,5.0
A,B,8.0
B,C,6.0
B,D,7.0
B,A,8.0
C,A,5.0
C,B,6.0
D,B,7.0
D,E,8.0
E,D,8.0
I want to convert it into following format of adjucency list.
"A"->List((8.0,"B"),(5.0,"C"))
Please guide me what is good way convert it into adjacency list in scala.
Since there's been no followup:
Parse the string into a Seq of Seq...
Make it into key, value. Value is a a single-element Seq because it makes
reduceByKey
easy to useWhere a (slightly simplistic)
reduceByKey
is("simplistic" because it always returns a Map rather than the same Traversable as the input).