I am working with JUNG Graph. The problem I am working on can be defined as follows:
Given a JUNG Graph G={V,E} and an edge E1, find the nodes/vertices that E1 connects and delete the vertex if it is a leaf node.
So, there are two parts:
Are these two operations directly possible in JUNG. If not, can someone suggest an alternate way to achieve the same.
(1) Graph.getIncidentVertices(E e1)
(2) You don't define what you mean by "leaf node", but assuming that you're referring to a directed graph and a vertex that has one incoming edge and no outgoing edges, that's easy:
Graph.getIncomingEdges().size() == 1
Graph.getOutgoingEdges().isEmpty())
If the graph is not a multigraph, you can also do this:
Graph.getPredecessorCount() == 1
Graph.getSuccessorCount() == 0
The Javadoc for JUNG is pretty good; you should consider browsing it before asking questions of this kind: http://jung.sourceforge.net/doc/api/index.html