creating an adjacency List for Graphs in Scala -


i have list of edges, undirected graph, saved in var edges: list[edge]. of them are.

a, b, 6 b, a, 6 a, d, 4 d, a, 4 b, c, 10 c, b, 10 b, d, 7 d, b, 7 b, e, 7 e, b, 7 c, d, 8 d, c, 8 c, e, 5 e, c, 5 c, f, 6 f, c, 6 d, e, 12 e, d, 12 e, f, 7 f, e, 7 

i trying put them in adjacency list, in way:

val adjlist: list[(vertex, list[vertex])] =        (graph.edges.groupby(_.source).map            { case (k,v) => (k, v.map {_.destination}) }).tolist 

but, it's not functional. doing wrong? :(

edit:


it not wrong (my mistake, read comment below)!

my given solution right. simply, wrong testing side. everybody's help.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -