Commit 09ec80f7 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge remote-tracking branch 'origin/454-dev-fix-graphology-edge-ids' into dev

parents 6f08b72a 1afa3fd5
...@@ -19,39 +19,37 @@ export function _mergeNodeAttributes(g, name, attrs) { ...@@ -19,39 +19,37 @@ export function _mergeNodeAttributes(g, name, attrs) {
} }
export function _addEdge(g, source, target, e) { 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 // Almost the same as graphology.mapNodes but with a change that only
// 1 argument is passed: the whole node structure // 1 argument is passed: the whole node structure
export function _mapNodes(g, fn) { export function _mapNodes(g, fn) {
return g.mapNodes(function(name, attrs) { return g.mapNodes(function(_name, attrs) {
return fn({id: name, ...attrs}); return fn(attrs);
}); });
} }
export function _filterNodes(g, fn) { export function _filterNodes(g, fn) {
return g.filterNodes(function(name, attrs) { return g.filterNodes(function(_name, attrs) {
return fn({id: name, ...attrs}); return fn(attrs);
}) })
} }
export function _forEachEdge(g, fn) { export function _forEachEdge(g, fn) {
return g.forEachEdge(function(name, attrs, source, target, sourceAttributes, targetAttributes, undirected) { return g.forEachEdge(function(_name, attrs, _source, _target, _sourceAttributes, _targetAttributes, _undirected) {
return fn({id: name, return fn(attrs);
source,
target,
...attrs});
}); });
} }
export function _updateEachEdgeAttributes(g, fn) { export function _updateEachEdgeAttributes(g, fn) {
return g.updateEachEdgeAttributes(function(name, attrs, source, target) { return g.updateEachEdgeAttributes(function(_name, attrs, _source, _target) {
return fn({id: name, return fn(attrs);
source,
target,
...attrs});
}); });
} }
...@@ -59,16 +57,13 @@ export function _updateEachEdgeAttributes(g, fn) { ...@@ -59,16 +57,13 @@ export function _updateEachEdgeAttributes(g, fn) {
// 1 argument is passed: the whole node structure // 1 argument is passed: the whole node structure
// https://graphology.github.io/iteration.html#mapedges // https://graphology.github.io/iteration.html#mapedges
export function _mapEdges(g, fn) { export function _mapEdges(g, fn) {
return g.mapEdges(function(name, attrs, source, target, sourceAttributes, targetAttributes, undirected) { return g.mapEdges(function(_name, attrs, _source, _target, _sourceAttributes, _targetAttributes, _undirected) {
return fn({id: name, return fn(attrs);
source,
target,
...attrs});
}); });
} }
export function _filterEdges(g, fn) { export function _filterEdges(g, fn) {
return g.filterEdges(function(name, attrs) { return g.filterEdges(function(_name, attrs) {
return fn({id: 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