Replies: 2 comments
-
Hello @mrckzgl
There is no official way to get this edge object sorry. There are multiple reasons for this, the first and foremost being that there exists more than a single implementation of the graphology specs and this edge object is only specific to the default implementation. This said, I see your point about having all the information at once. But usually, people don't need to because they have access to all this information as callback arguments or iterator entries when they navigate the graph. There are also (maybe undocumented yet) iteration methods for the whole sorted adjacency that forgo any avoidable hashmap lookups (note also that some of them are cleverly cached around to maximize performance). Some other partial answers: Can you elaborate on your use case a little bit more. |
Beta Was this translation helpful? Give feedback.
-
Hey, thanks for the fast answer! Currently the use case is as follows:
So there is a sigma instance where we need to listen for an edge to be clicked. The event is giving the edge key and we need all information from the edge to display further detailed information. To be fair, speed is not a concern here. I see the point about the other implementations, except that the spec design could dictate a function which would resolve an edge key to such an edge object. But it may be not of a problem if people don't need to go from a single edge key to the information an edge stores. For us, I will see how the project evolves and how we need to manipulate or retrieve the graph. For start it was just ... unexpected not having a function which resolves the key to something whole. Thanks also for the suggestions, extremities is convenient here. If I find more use cases, I will report them here. best |
Beta Was this translation helpful? Give feedback.
-
Hi, I am pretty new to graphology so excuse this simple question:
For a given edge key it is possible to get source, target, attributes with separate methods on the graph instance:
This is a bit tedious and also comparatively slow. Each function call needs to access the edge map and then the respective property of the edge object inside the edge map. Whereas already an edge object exists, which has all the information readily accessible:
However, accessing the edge object this way results in errors shown in the IDE, as _edges is marked as private attribute.
I surprisingly haven't found a function in the docs which allows to access these edge objects, but I would be very surprised if there is none as it is so obvious to return this to the user of the library.
So how to 'officially' get the edge object from the edge key?
best
Beta Was this translation helpful? Give feedback.
All reactions