Passing Variables in addNode
downlz opened this issue · 1 comments
downlz commented
While adding nodes to a path using route.addNode('B', { A:1, C:2, D: 4 })
instead of sending the nodes details directly if i send variable with the text ('B', { A:1, C:2, D: 4 })
it doesn't works.Does it always expects a object.Same goes for
const route = new Graph({
'A': { 'B': 1 },
'B': { 'A': 1, 'C': 2, 'D': 4 }
})
if i store networkMap as
'A': { 'B': 1 },
'B': { 'A': 1, 'C': 2, 'D': 4 }
and use the below
const route = new Graph({
networkMap
})
albertorestifo commented
That's because in the example you posted you're passing networkMap
as a property of the map.
You can instead pass networkMap
directly or use a destructuring assignment:
const route = new Graph(networkMap)
// OR (requires Node >6)
const route = new Graph({
...networkMap
})