January 2019
Beginner to intermediate
154 pages
4h 31m
English
One of the important operations of a graph is subgraph(). subgraph() allows users to filter out some of the parts of a graph based on a filter predicate. This predicate can be applied to either a vertex or an edge. The following code example shows how to create a new subgraph by filtering out vertices and edges:
//Scala//Filtering the edges which have relation other than 'friend'val edgeFilterGraph = graph.subgraph(epred = (edge) => edge.attr.equals("friend"))edgeFilterGraph.edges.collect()
As shown in the previous example, we are passing an edge predicate (epred) to filter out all the relation expect 'friend' relation. One important point to note here is that all the vertices will still be part of the new edgeFilterGraph. The
Read now
Unlock full access