Commit 32926a0e authored by unknown's avatar unknown

Merge branch 'nicolas/feature' into maximilian/newGraph

parents 8ce38c6f 6492088b
......@@ -82,6 +82,33 @@ export class Node2d {
})
return valueCounts
}
relatedSummary = (nodes, excludeHidden=false) => {
let valueCounts = {nodes: {}, links: {}}
const relatedIds = this.parents.ids().concat(this.targets.ids())
nodes.collectFromKeys(relatedIds).forEach(n => {
if (!(n.excluded && excludeHidden)){
if (valueCounts.nodes[n.type] && !(n.excluded && excludeHidden))
valueCounts.nodes[n.type] += 1
else
valueCounts.nodes[n.type] = 1
}})
this.parents.forEachEntry(link => {
if (valueCounts.links[link.type])
valueCounts.links[link.type] += 1
else
valueCounts.links[link.type] = 1
})
this.targets.forEachEntry(link => {
if (valueCounts.links[link.type])
valueCounts.links[link.type] += 1
else
valueCounts.links[link.type] = 1
})
return valueCounts
}
}
......
......@@ -351,9 +351,12 @@ export class Graph2d {
forEachCurrentNode = (f) => this._nodes.collectFromKeys([...this._currentNodes]).forEach(node => f(node))
getNodeSummary = (nodeId, condFn) => {
getNodeSummary = (nodeId, detailRelations=false, condFn) => {
const node = this._nodes.get(nodeId, condFn)
return node ? {parents: node.parentSummary(this._nodes), children: node.childrenSummary(this._nodes)}: null
if (detailRelations)
return node ? {parents: node.parentSummary(this._nodes), children: node.childrenSummary(this._nodes)}: null
else
return node ? node.relatedSummary(this._nodes): null
}
toGraphObj = () => ({
......
/**
* This module defines a new IdSet Class
* The IdSet class is made to behave like a Set, but the uses the field "id" of a class as key
* This allows us to use a Set like class but with object rather than primitive types
* This allows us to use a Set-like class but with object rather than primitive types
* */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment