*/
private long dfsTraverse (long parentIndex, long currIndex, long currSw,
Map<Long, ClusterDFS> dfsList, Set <Long> currSet) {
//Get the DFS object corresponding to the current switch
ClusterDFS currDFS = dfsList.get(currSw);
// Get all the links corresponding to this switch
Set<Long> nodesInMyCluster = new HashSet<Long>();
Set<Long> myCurrSet = new HashSet<Long>();
//Assign the DFS object with right values.
currDFS.setVisited(true);
currDFS.setDfsIndex(currIndex);
currDFS.setParentDFSIndex(parentIndex);
currIndex++;
// Traverse the graph through every outgoing link.
if (switchPorts.get(currSw) != null){
for(Short p: switchPorts.get(currSw)) {
Set<Link> lset = switchPortLinks.get(new NodePortTuple(currSw, p));
if (lset == null) continue;
for(Link l:lset) {
long dstSw = l.getDst();
// ignore incoming links.
if (dstSw == currSw) continue;
// ignore if the destination is already added to
// another cluster
if (switchClusterMap.get(dstSw) != null) continue;
// ignore the link if it is blocked.
if (isBlockedLink(l)) continue;
// ignore this link if it is in broadcast domain
if (isBroadcastDomainLink(l)) continue;
// Get the DFS object corresponding to the dstSw
ClusterDFS dstDFS = dfsList.get(dstSw);
if (dstDFS.getDfsIndex() < currDFS.getDfsIndex()) {
// could be a potential lowpoint
if (dstDFS.getDfsIndex() < currDFS.getLowpoint())
currDFS.setLowpoint(dstDFS.getDfsIndex());
} else if (!dstDFS.isVisited()) {
// make a DFS visit
currIndex = dfsTraverse(currDFS.getDfsIndex(), currIndex, dstSw,
dfsList, myCurrSet);
if (currIndex < 0) return -1;
// update lowpoint after the visit
if (dstDFS.getLowpoint() < currDFS.getLowpoint())
currDFS.setLowpoint(dstDFS.getLowpoint());
nodesInMyCluster.addAll(myCurrSet);
myCurrSet.clear();
}
// else, it is a node already visited with a higher