%libraryDependencies += "org.viz.lightning" %% "lightning-scala" % "0.1.6"

%update

import org.viz.lightning._
import org.apache.spark.graphx._

val lgn = Lightning(host="https://lightning-spark-summit.herokuapp.com" )
lgn.enableNotebook()

"""
Explanation: * Visualizing of genetic similarity with Lightning + GraphX *
Setup lightning
End of explanation
"""


val source = "/Users/mathisonian/projects/spark-summit/notebooks/data/allen-connectivity.txt"
val g = GraphLoader.edgeListFile(sc, source)

"""
Explanation: Load structure similarity data
Public data from http://www.brain-map.org/
End of explanation
"""


val links = g.edges.collect().map(e => Array(e.srcId.toInt, e.dstId.toInt))

lgn.force(links)

"""
Explanation: Show the network (unlabeled)
End of explanation
"""


val links = g.edges.collect().map(e => Array(e.srcId.toInt, e.dstId.toInt))
val degrees = g.degrees.sortBy(_._1).collect().map(x => Math.log(x._2))

lgn.force(links, value=degrees, colormap="Lightning")

"""
Explanation: Show the network colored by degree
End of explanation
"""


val links = g.edges.collect().map(e => Array(e.srcId.toInt, e.dstId.toInt))
val connectedComponents = g.connectedComponents().vertices.sortBy(_._1).map(_._2.toInt).collect()

lgn.force(links, label=connectedComponents)

"""
Explanation: Show the network colored by connected components
End of explanation
"""


