This repository has been archived by the owner on Nov 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3832439
commit 93db307
Showing
5 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
var Node = require('../index.js'); | ||
var Graph = require('./helpers/graph.js'); | ||
var assert = require('assert'); | ||
|
||
describe('Cross-edge', function() { | ||
var graph; | ||
beforeEach(function() { | ||
graph = new Graph({ | ||
a: new Node(), | ||
b: new Node(), | ||
c: new Node(), | ||
}); | ||
|
||
// -------- | ||
// v \ | ||
// a -> b -> c | ||
// \ ^ | ||
// -------- | ||
|
||
graph.connect('a', 'b'); | ||
graph.connect('b', 'c'); | ||
graph.connect('a', 'c'); | ||
graph.connect('c', 'a'); | ||
return graph.propagate(); | ||
}); | ||
|
||
it('should find both cycles', function() { | ||
assert.deepEqual(graph.nodes.a.getActiveNeighbors(), { | ||
'in': ['c'], | ||
out: ['b', 'c'], | ||
}); | ||
assert.deepEqual(graph.nodes.b.getActiveNeighbors(), { | ||
'in': ['a'], | ||
out: ['c'], | ||
}); | ||
assert.deepEqual(graph.nodes.c.getActiveNeighbors(), { | ||
'in': ['b', 'a'], | ||
out: ['a'], | ||
}); | ||
}); | ||
describe('incoming probe message for a', function() { | ||
beforeEach(function() { | ||
graph.nodes.a.handleProbeMessage('c', 'in', { | ||
treeToken: 'asdf', | ||
}); | ||
return graph.propagate(); | ||
}); | ||
it('a should not find a route', function() { | ||
assert.equal(graph.nodes.a._cycleFound, true); | ||
}); | ||
it('b should not find a route', function() { | ||
assert.equal(graph.nodes.b._cycleFound, false); | ||
}); | ||
it('c should not find a route', function() { | ||
assert.equal(graph.nodes.c._cycleFound, false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters