Graphics Reference
In-Depth Information
One customer has been responsible for almost a million reviews, which is
impossibly high. It seems someone has found a way to artificially submit
reviews. Those edges will need to be excluded.
The final step is to create a new subgraph, adding copies of the neighboring
nodes and any edges that connect them (but no others), and then write the
result to file. Begin by creating an in-memory TinkerGraph and declare
two helper functions that will copy nodes and links, as shown here:
gremlin> sg = new TinkerGraph()
==>tinkergraph[vertices:0 edges:0]
gremlin> def addNode(v, sg){
sg.addVertex(v.id, ElementHelper.getProperties(v))
}
==>true
gremlin> def addLink(e, sg) {
outv = sg.getVertex(e.outV.next().id);
if (outv != null) {
inv = sg.getVertex(e.inV.next().id);
if (inv != null) {
sg.addEdge(e.id, outv, inv, e.label,
ElementHelper.getProperties
(e))
}}}
==>true
Add linked customers and products, being sure to filter out the false
customer, and eliminate any duplicate nodes. Use store to cache the list of
products for the next step, which will be to add the edges.
gremlin> products = []
gremlin> tufteBook.in('review').filter{it.outE.count()
< 5000}.dedup
(
).sideEffect{addNode(it,sg)}.out().or(tufteBook.both('similar')).
dedup(
).sideEffect{addNode(it,sg)}.store(products)
Search WWH ::




Custom Search