Created
April 27, 2014 21:54
-
-
Save adispen/11356591 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void shortestPath(Vertex[] friendGraph, String name1, String name2){ | |
name1 = name1.toLowerCase(); | |
name2 = name2.toLowerCase(); | |
int n1Index = 0; | |
Stack<Vertex> friendStack = new Stack<Vertex>(); | |
for(int j = 0; friendGraph[j].neighborList.next != null; j++){ | |
System.out.println(friendGraph[j].name); | |
if(friendGraph[j].name.toLowerCase().equals(name1)){ | |
n1Index = j; | |
} | |
if(friendGraph[j+1] == null){ | |
continue; | |
} | |
} | |
friendStack = bfs(name2, n1Index, friendGraph); | |
while(!friendStack.empty()){ | |
System.out.print(friendStack.pop().name + "--"); | |
} | |
System.out.print(name2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment