Hello! I am using ngraph.graph version ^20.0.0 as specified in my package.json.
I am creating a graph from a file planet-route-data.json like so:
import createGraph from 'ngraph.graph'
function makeTravelGraph () {
const graph = createGraph()
const travelGraphData = JSON.parse(fs.readFileSync('./src/planet-route-data.json'))
// first, we create nodes
travelGraphData.forEach(sourcePlanet => {
graph.addNode(sourcePlanet.name)
})
// then, we link them
travelGraphData.forEach(sourcePlanet => {
sourcePlanet.destinations.forEach(destination => {
graph.addLink(sourcePlanet.name, destination.name, { fuelCost: destination.cost })
})
})
return graph
}
My planet-route-data.json file looks like this (please ignore the values themselves, haha):
[
{
"name": "Earth",
"destinations": [
{
"name": "Mars",
"cost": 13
},
{
"name": "Venus",
"cost": 23
}
]
},
{
"name": "Mars",
"destinations": [
{
"name": "Jupiter",
"cost": 22
},
{
"name": "Saturn",
"cost": 25
}
]
},
{
"name": "Saturn",
"destinations": [
{
"name": "Jupiter",
"cost": 30
},
{
"name": "Earth",
"cost": 12
}
]
},
{
"name": "Venus",
"destinations": [
{
"name": "Earth",
"cost": 20
},
{
"name": "Mars",
"cost": 25
},
{
"name": "Mercury",
"cost": 15
}
]
}
]
The nodes in the graph are being created, and links seem to be created successfully -- that is, I can list them as expected with something like:
returnedGraph.forEachLink(link => {
console.log(link)
}
However, the nodes themselves, which contain a property named links, do not seem to be updated. If I try to print them, their links property looks like an empty object: {}. If I do:
returnedGraph.forEachLinkedNode(node => {
console.log(node)
}
nothing is iterated upon, presumably as there are no nodes with links to be found.
Is this, by any chance, by design, or is it not intended behavior?
Hello! I am using
ngraph.graphversion^20.0.0as specified in mypackage.json.I am creating a graph from a file
planet-route-data.jsonlike so:My
planet-route-data.jsonfile looks like this (please ignore the values themselves, haha):[ { "name": "Earth", "destinations": [ { "name": "Mars", "cost": 13 }, { "name": "Venus", "cost": 23 } ] }, { "name": "Mars", "destinations": [ { "name": "Jupiter", "cost": 22 }, { "name": "Saturn", "cost": 25 } ] }, { "name": "Saturn", "destinations": [ { "name": "Jupiter", "cost": 30 }, { "name": "Earth", "cost": 12 } ] }, { "name": "Venus", "destinations": [ { "name": "Earth", "cost": 20 }, { "name": "Mars", "cost": 25 }, { "name": "Mercury", "cost": 15 } ] } ]The nodes in the graph are being created, and links seem to be created successfully -- that is, I can list them as expected with something like:
However, the nodes themselves, which contain a property named
links, do not seem to be updated. If I try to print them, theirlinksproperty looks like an empty object:{}. If I do:nothing is iterated upon, presumably as there are no nodes with links to be found.
Is this, by any chance, by design, or is it not intended behavior?