BridgesUNCC / bridges-java

JAVA Client library for Bridges
http://bridgesuncc.github.io
GNU General Public License v2.0
4 stars 12 forks source link

NullPointerException with outgoingEdgeSetOf #158

Closed acbart closed 4 years ago

acbart commented 4 years ago

I believe this is being caused by trying to access the outgoingEdgeSetOf of a vertex that has no neighbors. So something like:

GraphAdjList<String, Room, Connection> graph = new GraphAdjList<>();
graph.addVertex("Alpha", room);
graph.outgoingEdgeSetOf("Alpha");
acbart commented 4 years ago

Or perhaps, more accurately, it's returning null in that case, and I was dereferencing it later on. Either way, not necessarily the behavior I expected for this helper function. But makes sense I suppose.

krs-world commented 4 years ago

The method should be returning an iterable object  that should make it easy to modify the edge's properties. Check the graph adjacency list tutorial. This should avoid this issue..

http://bridgesuncc.github.io/tutorials/Graph_AL.html

If its not doing that, let us know.

    -- krs

On 4/1/20 7:10 AM, Austin Cory Bart wrote:

Or perhaps, more accurately, it's returning null in that case, and I was dereferencing it later on. Either way, not necessarily the behavior I expected for this helper function. But makes sense I suppose.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BridgesUNCC/bridges-java/issues/158#issuecomment-607185818, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLFEOAGA3WJZI5BQXRV5O3RKMOJLANCNFSM4LYZE7KQ.

-- Kalpathi Subramanian Ph: 704 687 8579 Associate Professor Email: krs@uncc.edu Dept of Computer Science Web:http://webpages.uncc.edu/krs The University of North Carolina Charlotte, NC 28223-0001

acbart commented 4 years ago

Ah, then yes I think this is misbehaving. I think you need to add if (graph.getAdjacencyList(vertex) != null) { around it in case there are no adjacent nodes.

AlecGoncharow commented 4 years ago

You are correct, this should not happen. Will push a fix soon.