Commit 1afa3fd5 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[graph] refactor edges to use our ids

...not the ones auto-generated by sigma.
parent 09a5846c
Pipeline #3311 failed with stage
in 0 seconds
......@@ -19,39 +19,37 @@ export function _mergeNodeAttributes(g, name, attrs) {
}
export function _addEdge(g, source, target, e) {
return g.addEdge(source, target, e);
//return g.addEdge(source, target, e);
// NOTE: Our edge.id is the main key. We don't need sigma
// auto-generated keys for edges
return g.addEdgeWithKey(e.id, source, target, e);
}
// Almost the same as graphology.mapNodes but with a change that only
// 1 argument is passed: the whole node structure
export function _mapNodes(g, fn) {
return g.mapNodes(function(name, attrs) {
return fn({id: name, ...attrs});
return g.mapNodes(function(_name, attrs) {
return fn(attrs);
});
}
export function _filterNodes(g, fn) {
return g.filterNodes(function(name, attrs) {
return fn({id: name, ...attrs});
return g.filterNodes(function(_name, attrs) {
return fn(attrs);
})
}
export function _forEachEdge(g, fn) {
return g.forEachEdge(function(name, attrs, source, target, sourceAttributes, targetAttributes, undirected) {
return fn({id: name,
source,
target,
...attrs});
return g.forEachEdge(function(_name, attrs, _source, _target, _sourceAttributes, _targetAttributes, _undirected) {
return fn(attrs);
});
}
export function _updateEachEdgeAttributes(g, fn) {
return g.updateEachEdgeAttributes(function(name, attrs, source, target) {
return fn({id: name,
source,
target,
...attrs});
return g.updateEachEdgeAttributes(function(_name, attrs, _source, _target) {
return fn(attrs);
});
}
......@@ -59,16 +57,13 @@ export function _updateEachEdgeAttributes(g, fn) {
// 1 argument is passed: the whole node structure
// https://graphology.github.io/iteration.html#mapedges
export function _mapEdges(g, fn) {
return g.mapEdges(function(name, attrs, source, target, sourceAttributes, targetAttributes, undirected) {
return fn({id: name,
source,
target,
...attrs});
return g.mapEdges(function(_name, attrs, _source, _target, _sourceAttributes, _targetAttributes, _undirected) {
return fn(attrs);
});
}
export function _filterEdges(g, fn) {
return g.filterEdges(function(name, attrs) {
return fn({id: name, ...attrs});
return g.filterEdges(function(_name, attrs) {
return fn(attrs);
})
}
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