From 6f11a89df56584b241e0b0cf7f8942cbbd824012 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Wed, 28 Nov 2012 21:48:01 -0500 Subject: [PATCH 01/33] Update friends/Graph_Methods.java --- friends/Graph_Methods.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/friends/Graph_Methods.java b/friends/Graph_Methods.java index 46dc4b2..9d7e9d6 100644 --- a/friends/Graph_Methods.java +++ b/friends/Graph_Methods.java @@ -3,12 +3,7 @@ import java.io.*; import java.util.StringTokenizer; -/** - * This class implements a term of a polynomial. - * - * @author runb-cs112 - * - */ + class Term { /** * name of term. From 952cfc209c06efc70b87e374940601dea402f587 Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Wed, 28 Nov 2012 22:49:14 -0500 Subject: [PATCH 02/33] worked on build --- friends/Graph_Methods.java | 53 +++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/friends/Graph_Methods.java b/friends/Graph_Methods.java index 46dc4b2..e34895b 100644 --- a/friends/Graph_Methods.java +++ b/friends/Graph_Methods.java @@ -1,6 +1,7 @@ package graph; import java.io.*; +import java.util.ArrayList; import java.util.StringTokenizer; /** @@ -132,23 +133,39 @@ public Graph_Methods() { * @param br BufferedReader from which a polynomial is to be read * @throws IOException If there is any input error in reading the polynomial */ - public Polynomial(BufferedReader br) throws IOException { - String line; - StringTokenizer tokenizer; - float name; - int school; - - poly = null; - - while ((line = br.readLine()) != null) { - tokenizer = new StringTokenizer(line); - name = Float.parseFloat(tokenizer.nextToken()); - school = Integer.parseInt(tokenizer.nextToken()); - poly = new Node(name, school, poly); - } - } +// public Polynomial(BufferedReader br) throws IOException { +// String line; +// StringTokenizer tokenizer; +// float name; +// int school; +// +// poly = null; +// +// while ((line = br.readLine()) != null) { +// tokenizer = new StringTokenizer(line); +// name = Float.parseFloat(tokenizer.nextToken()); +// school = Integer.parseInt(tokenizer.nextToken()); +// poly = new Node(name, school, poly); +// } +// } - public build() + public void build(String[] people, ArrayList friends){ + Person[] zoo = new Person[people.length]; + for(int i=0; i Date: Wed, 28 Nov 2012 23:45:32 -0500 Subject: [PATCH 03/33] Update friends/Graph_Methods.java --- friends/Graph_Methods.java | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/friends/Graph_Methods.java b/friends/Graph_Methods.java index ebbafe2..c9ee014 100644 --- a/friends/Graph_Methods.java +++ b/friends/Graph_Methods.java @@ -144,28 +144,40 @@ public Graph_Methods() { // } // } - public void build(String[] people, ArrayList friends){ + public Person[] build(String[] people, ArrayList friends){ Person[] zoo = new Person[people.length]; for(int i=0; i Date: Thu, 29 Nov 2012 11:30:41 -0500 Subject: [PATCH 04/33] Update friends/Graph_Methods.java --- friends/Graph_Methods.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/friends/Graph_Methods.java b/friends/Graph_Methods.java index c9ee014..5127848 100644 --- a/friends/Graph_Methods.java +++ b/friends/Graph_Methods.java @@ -161,18 +161,22 @@ public Person[] build(String[] people, ArrayList friends){ zoo[i]= body; //put him in the zoo } - for(int j=0; j Date: Thu, 29 Nov 2012 11:32:06 -0500 Subject: [PATCH 05/33] Update friends/Person.java --- friends/Person.java | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/friends/Person.java b/friends/Person.java index 9598c0a..e671841 100644 --- a/friends/Person.java +++ b/friends/Person.java @@ -5,22 +5,24 @@ public class Person{ public String name; public String school; - //public ArrayList friendList; + public Person next; + public ArrayList friendList; - public Person(String name, String school){ //ArrayList friendList + public Person(String name, String school, Person next){ //ArrayList friendList this.name = name; this.school = school; + this.next = next; //this.friendList = friendList; } } -class friendList{ - Person person; - friendList next; - - public friendList(String name, String school, friendList next){ - person = new Person(name, school); - this.next = next; - } -} +//class friendList{ +// Person person; +// friendList next; +// +// public friendList(String name, String school, friendList next){ +// person = new Person(name, school); +// +// } +//} From 70fbad244862856a81cb558b8d5a1a660fa0efc4 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Thu, 29 Nov 2012 11:33:05 -0500 Subject: [PATCH 06/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index 7004440..925854a 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -74,8 +74,8 @@ public static void main(String[] args) throws IOException { line = br2.readLine(); friendsBuk.add(line); } - - //build graph here + Person[] graph = new Person[count]; + graph = build(personBuk, friendsBuk); int choice = getChoice(); while (choice != QUIT) { From f1dd78f9ce36383964a73cf307da0223b566c20e Mon Sep 17 00:00:00 2001 From: stewsmith Date: Thu, 29 Nov 2012 12:13:40 -0500 Subject: [PATCH 07/33] Update friends/Graph_Methods.java --- friends/Graph_Methods.java | 40 +------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/friends/Graph_Methods.java b/friends/Graph_Methods.java index 5127848..b8d0c6a 100644 --- a/friends/Graph_Methods.java +++ b/friends/Graph_Methods.java @@ -104,45 +104,7 @@ public Graph_Methods() { poly = null; } - /** - * Reads a polynomial from an input stream (file or keyboard). The storage format - * of the polynomial is: - *
-     *      
-     *      
-     *     ...
-     *      
-     * 
- * with the guarantee that schools will be in descending order. For example: - *
-     *      4 5
-     *     -2 3
-     *      2 1
-     *      3 0
-     * 
- * which represents the polynomial: - *
-     *      4*x^5 - 2*x^3 + 2*x + 3
-     * 
- * - * @param br BufferedReader from which a polynomial is to be read - * @throws IOException If there is any input error in reading the polynomial - */ -// public Polynomial(BufferedReader br) throws IOException { -// String line; -// StringTokenizer tokenizer; -// float name; -// int school; -// -// poly = null; -// -// while ((line = br.readLine()) != null) { -// tokenizer = new StringTokenizer(line); -// name = Float.parseFloat(tokenizer.nextToken()); -// school = Integer.parseInt(tokenizer.nextToken()); -// poly = new Node(name, school, poly); -// } -// } + public Person[] build(String[] people, ArrayList friends){ Person[] zoo = new Person[people.length]; From 09cba625bc37f4c63c66be9f89dbf195abd59a63 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Thu, 29 Nov 2012 12:26:40 -0500 Subject: [PATCH 08/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index 925854a..5008059 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -74,7 +74,7 @@ public static void main(String[] args) throws IOException { line = br2.readLine(); friendsBuk.add(line); } - Person[] graph = new Person[count]; + Person[] graph = new Person[count]; //I understadn this is initiallizing the graph but what is Person[count]? graph = build(personBuk, friendsBuk); int choice = getChoice(); From b8c3dbee95a734558f5d35efcba61ddb91bdc53b Mon Sep 17 00:00:00 2001 From: stewsmith Date: Thu, 29 Nov 2012 12:30:00 -0500 Subject: [PATCH 09/33] Update friends/Graph_Methods.java --- friends/Graph_Methods.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/friends/Graph_Methods.java b/friends/Graph_Methods.java index b8d0c6a..bb2929c 100644 --- a/friends/Graph_Methods.java +++ b/friends/Graph_Methods.java @@ -107,7 +107,7 @@ public Graph_Methods() { public Person[] build(String[] people, ArrayList friends){ - Person[] zoo = new Person[people.length]; + Person[] zoo = new Person[people.length]; // does zoo need to be a gloabal variable? for(int i=0; i Date: Thu, 29 Nov 2012 12:56:33 -0500 Subject: [PATCH 10/33] Update friends/Graph_Methods.java --- friends/Graph_Methods.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/friends/Graph_Methods.java b/friends/Graph_Methods.java index bb2929c..933faeb 100644 --- a/friends/Graph_Methods.java +++ b/friends/Graph_Methods.java @@ -137,7 +137,7 @@ public Person[] build(String[] people, ArrayList friends){ if(zoo[k].name.equalsIgnoreCase(second)){ secondPerson = zoo[k]; } - firstPerson.next = secondPerson; + firstPerson.next = secondPerson; //it looks like every time a new friend is added we lose a pointer to the pervious frineds secondPerson.next = firstPerson; } From d32be4dd1e06cfaf3abbc17ac0381d59822437a5 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Thu, 29 Nov 2012 19:26:21 -0500 Subject: [PATCH 11/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index 5008059..0259e87 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -74,7 +74,7 @@ public static void main(String[] args) throws IOException { line = br2.readLine(); friendsBuk.add(line); } - Person[] graph = new Person[count]; //I understadn this is initiallizing the graph but what is Person[count]? + Person[] graph = new Person[count]; //ANS: Person[count] is the syntax to make an person array with size count graph = build(personBuk, friendsBuk); int choice = getChoice(); From 192fab7bc7cf33c31ef971e26f4e3920622476b2 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Thu, 29 Nov 2012 19:45:05 -0500 Subject: [PATCH 12/33] Update friends/Graph_Methods.java --- friends/Graph_Methods.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/friends/Graph_Methods.java b/friends/Graph_Methods.java index 933faeb..8ffd07b 100644 --- a/friends/Graph_Methods.java +++ b/friends/Graph_Methods.java @@ -137,8 +137,16 @@ public Person[] build(String[] people, ArrayList friends){ if(zoo[k].name.equalsIgnoreCase(second)){ secondPerson = zoo[k]; } - firstPerson.next = secondPerson; //it looks like every time a new friend is added we lose a pointer to the pervious frineds - secondPerson.next = firstPerson; + if(firstPerson.next != null){ //attach the second friend to the + Person temp = firstPerson.next; //first without losing old friend chain + firstPerson.next = secondPerson; + secondPerson.next = temp; + }else firstPerson.next = secondPerson; + if(secondPerson.next != null){ //attach the first friend to the second + Person temp = secondPerson.next; //without losing old friend chain + secondPerson.next = firstPerson; + firstPerson.next = temp; + }else secondPerson.next = firstPerson; } } From 7d4afc8b149e628d0e0f02692779f8087af0fd0e Mon Sep 17 00:00:00 2001 From: stewsmith Date: Thu, 29 Nov 2012 19:49:21 -0500 Subject: [PATCH 13/33] Update friends/Graph_Methods.java --- friends/Graph_Methods.java | 163 ++++++------------------------------- 1 file changed, 27 insertions(+), 136 deletions(-) diff --git a/friends/Graph_Methods.java b/friends/Graph_Methods.java index 8ffd07b..a39e39a 100644 --- a/friends/Graph_Methods.java +++ b/friends/Graph_Methods.java @@ -1,9 +1,8 @@ -package graph; +package friends; -import java.io.*; -import java.util.ArrayList; -import java.util.StringTokenizer; +import java.io.*; +import java.util.*; class Term { /** @@ -16,114 +15,28 @@ class Term { */ public String school; - /** - * Initializes an instance with given name and school. - * - * @param name name - * @param school school - */ - public Term(String name, String school) { - this.name = name; - this.school = school; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object other) { - return other != null && - other instanceof Term && - name == ((Term)other).name && - school == ((Term)other).school; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - if (school == "") { - return name + ""; - } else if (school == 1) { - return name + "x"; - } else { - return name + "x^" + school; - } - } -} - -/** - * This class implements a linked list node that contains a Term instance. - * - * @author runb-cs112 - * - */ -class Node { - - /** - * Term instance. - */ - Term term; - - /** - * Next node in linked list. - */ - Node next; - - /** - * Initializes this node with a term with given name and school, - * pointing to the given next node. - * - * @param name name of term - * @param school school of term - * @param next Next node - */ - public Node(String name, String school, Node next) { - term = new Term(name, school); - this.next = next; - } -} - -/** - * This class implements a polynomial. - * - * @author runb-cs112 - * - */ -public class Graph_Methods { - - /** - * Pointer to the front of the linked list that stores the polynomial. - */ - Node poly; - - /** - * Initializes this polynomial to empty, i.e. there are no terms. - * - */ - public Graph_Methods() { - poly = null; - } - - - public Person[] build(String[] people, ArrayList friends){ - Person[] zoo = new Person[people.length]; // does zoo need to be a gloabal variable? - for(int i=0; i friends){ + Person[] zoo = new Person[people.length]; + for(int i=0; i friends){ if(zoo[k].name.equalsIgnoreCase(second)){ secondPerson = zoo[k]; } - if(firstPerson.next != null){ //attach the second friend to the - Person temp = firstPerson.next; //first without losing old friend chain + if(firstPerson.next != null){ //attach the second friend to the first without losing old friend chain + Person temp = firstPerson.next; firstPerson.next = secondPerson; secondPerson.next = temp; }else firstPerson.next = secondPerson; - if(secondPerson.next != null){ //attach the first friend to the second - Person temp = secondPerson.next; //without losing old friend chain + if(secondPerson.next != null){ //attach the first friend to the second without losing old friend chain + Person temp = secondPerson.next; secondPerson.next = firstPerson; firstPerson.next = temp; }else secondPerson.next = firstPerson; @@ -152,46 +65,24 @@ public Person[] build(String[] people, ArrayList friends){ } return zoo; //temporary return } - - /** - * Returns the polynomial obtained by multiplying the given polynomial p - * with this polynomial - DOES NOT change this polynomial - * - * @param p Polynomial with which this polynomial is to be multiplied - * @return A new polynomial which is the product of this polynomial and p. - */ - public void multiply() { + + public Person subgraph(String school) { /** COMPLETE THIS METHOD **/ - + return null; } - /** - * Evaluates this polynomial at the given value of x - * - * @param x Value at which this polynomial is to be evaluated - * @return Value of this polynomial at x - */ - public float evaluate(float x) { + + public void shortest(String lonely, String desired) { /** COMPLETE THIS METHOD **/ - return 0; + } - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - String retval; + + public void cliques(String school) { + /** COMPLETE THIS METHOD **/ - if (poly == null) { - return "0"; - } else { - retval = poly.term.toString(); - for (Node current = poly.next ; - current != null ; - current = current.next) { - retval = current.term.toString() + " + " + retval; - } - return retval; - } } + + + } From 0e287f5bc12a29fbac34b25320ce6c0c9b56463a Mon Sep 17 00:00:00 2001 From: stewsmith Date: Thu, 29 Nov 2012 19:50:08 -0500 Subject: [PATCH 14/33] Update friends/Graph_Methods.java --- friends/Graph_Methods.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/friends/Graph_Methods.java b/friends/Graph_Methods.java index a39e39a..31e5683 100644 --- a/friends/Graph_Methods.java +++ b/friends/Graph_Methods.java @@ -83,6 +83,10 @@ public void cliques(String school) { } + public void connectors() { + /** COMPLETE THIS METHOD **/ + + } } From 45349228ae4afc5b293fc4a3ea778ff86d2ee423 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Thu, 29 Nov 2012 21:45:42 -0500 Subject: [PATCH 15/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 69 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index 0259e87..8020acf 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -58,7 +58,7 @@ public static void main(String[] args) throws IOException { System.out.print("Enter the name of the friendship file => "); br2 = new BufferedReader(new FileReader(br1.readLine())); - int count = Integer.parseInt(br2.readLine())+1; //number of people + int count = Integer.parseInt(br2.readLine())+1; //number of people String[] personBuk = new String[count]; for(int i=0; i friends){ + Person[] zoo = new Person[people.length]; + for(int i=0; i Date: Thu, 29 Nov 2012 21:55:01 -0500 Subject: [PATCH 16/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index 8020acf..fc905e2 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -123,8 +123,8 @@ public static Person[] build(String[] people, ArrayList friends){ String raw = friends.get(j); String first = raw.substring(0, raw.indexOf('|')); //the first friend name String second = raw.substring(raw.indexOf('|')+1); //the second friend name - Person firstPerson = new Person(null, null, null); - Person secondPerson = new Person(null, null, null); + Person firstPerson; + Person secondPerson; boolean firstAssigned = false; boolean secAssigned = false; From 0e40b49c9993ac4589be5e98cca6da76c742cb25 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Fri, 30 Nov 2012 14:57:38 -0500 Subject: [PATCH 17/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 295 ++++++++++++++++++++-------------------- 1 file changed, 144 insertions(+), 151 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index fc905e2..ecf8f1c 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -6,155 +6,148 @@ public class Graph_Test { - static BufferedReader br1, br2; - static Scanner stdin = new Scanner(System.in); - - public static final int STUDENTS = 1; - public static final int SHORT = 2; - public static final int CLIQUE = 3; - public static final int CONNECT = 4; - public static final int QUIT = 5; - - public static int getChoice() - throws IOException { - System.out.println(); - System.out.println(STUDENTS + ". Students at school"); - System.out.println(SHORT + ". Shortest intro chain"); - System.out.println(CLIQUE + ". Cliques at school"); - System.out.println(CONNECT + ". Connectors"); - System.out.println(QUIT + ". QUIT"); - System.out.print("\tEnter choice # => "); - return (Integer.parseInt(br1.readLine())); - } - - public static void subgraph() - throws IOException { - System.out.print("Enter the name of the school => "); - String sc = stdin.nextLine(); - - } - - public static void shortest() - throws IOException { - System.out.print("Enter the name of the lonely boy => "); - String lone = stdin.nextLine(); - - } - - public static void cliques() - throws IOException { - System.out.println("Enter the name of the school => "); - String x = stdin.nextLine(); - - } - - public static void connectors(){ - - - } - - public static void main(String[] args) throws IOException { - br1 = new BufferedReader(new InputStreamReader(System.in)); - System.out.print("Enter the name of the friendship file => "); - br2 = new BufferedReader(new FileReader(br1.readLine())); - - int count = Integer.parseInt(br2.readLine())+1; //number of people - String[] personBuk = new String[count]; - - for(int i=0; i friendsBuk = new ArrayList(); - String line = br2.readLine(); - friendsBuk.add(line); - - while(line != null){ //put the friends line in an array - line = br2.readLine(); - friendsBuk.add(line); - } - - Person[] graph = new Person[count]; - - graph = build(personBuk, friendsBuk); //FUCK HOW DOES THIS SYNTAX WORK?!?! - - System.out.println(graph); - - - int choice = getChoice(); - while (choice != QUIT) { - if (choice < 1 || choice > QUIT) { - System.out.println("\tIncorrect choice " + choice); - } else { - switch (choice) { - case STUDENTS: subgraph(); break; - case SHORT: shortest(); break; - case CLIQUE: cliques(); break; - case CONNECT: connectors(); break; //revise - default: break; - } - } - choice = getChoice(); - } - - } - - public static Person[] build(String[] people, ArrayList friends){ - Person[] zoo = new Person[people.length]; - for(int i=0; i "); + return (Integer.parseInt(br1.readLine())); + } + + public static void subgraph() + throws IOException { + System.out.print("Enter the name of the school => "); + String sc = stdin.nextLine(); + + } + + public static void shortest() + throws IOException { + System.out.print("Enter the name of the lonely boy => "); + String lone = stdin.nextLine(); + + } + + public static void cliques() + throws IOException { + System.out.println("Enter the name of the school => "); + String x = stdin.nextLine(); + + } + + public static void connectors(){ + + + } + + public static void main(String[] args) throws IOException { + br1 = new BufferedReader(new InputStreamReader(System.in)); + System.out.print("Enter the name of the friendship file => "); + br2 = new BufferedReader(new FileReader(br1.readLine())); + + int count = Integer.parseInt(br2.readLine())+1; //number of people + String[] personBuk = new String[count]; + + for(int i=0; i friendsBuk = new ArrayList(); + String line = br2.readLine(); + friendsBuk.add(line); + + while(line != null){ //put the friends line in an array + line = br2.readLine(); + friendsBuk.add(line); + } + + Person[] graph = new Person[count]; + + graph = build(personBuk, friendsBuk); //FUCK HOW DOES THIS SYNTAX WORK?!?! + + System.out.println(graph); + + + int choice = getChoice(); + while (choice != QUIT) { + if (choice < 1 || choice > QUIT) { + System.out.println("\tIncorrect choice " + choice); + } else { + switch (choice) { + case STUDENTS: subgraph(); break; + case SHORT: shortest(); break; + case CLIQUE: cliques(); break; + case CONNECT: connectors(); break; //revise + default: break; + } + } + choice = getChoice(); + } + + } + + public static Person[] build(String[] people, ArrayList friends){ + Person[] zoo = new Person[people.length]; + for(int i=0; i Date: Fri, 30 Nov 2012 17:00:09 -0500 Subject: [PATCH 18/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 55 +++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index ecf8f1c..69d780b 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -26,13 +26,7 @@ public static int getChoice() System.out.print("\tEnter choice # => "); return (Integer.parseInt(br1.readLine())); } - - public static void subgraph() - throws IOException { - System.out.print("Enter the name of the school => "); - String sc = stdin.nextLine(); - - } + public static void shortest() throws IOException { @@ -59,9 +53,9 @@ public static void main(String[] args) throws IOException { br2 = new BufferedReader(new FileReader(br1.readLine())); int count = Integer.parseInt(br2.readLine())+1; //number of people - String[] personBuk = new String[count]; + String[] personBuk = new String[count-1]; - for(int i=0; i QUIT) { System.out.println("\tIncorrect choice " + choice); } else { switch (choice) { - case STUDENTS: subgraph(); break; + case STUDENTS: + System.out.print("Enter the name of the school => "); + String sc = stdin.nextLine(); + subgraph(sc, graph); break; case SHORT: shortest(); break; case CLIQUE: cliques(); break; case CONNECT: connectors(); break; //revise @@ -97,7 +90,6 @@ public static void main(String[] args) throws IOException { } choice = getChoice(); } - } public static Person[] build(String[] people, ArrayList friends){ @@ -134,7 +126,7 @@ public static Person[] build(String[] people, ArrayList friends){ if (zoo[k].name.equalsIgnoreCase(second)){ secDex.friendNum=k; secMatched=true; - } + } if(firstMatched && secMatched){ Friendex temp1 = zoo[firstDex.friendNum].front; //keep the chain that is already attached Friendex temp2 = zoo[secDex.friendNum].front; @@ -148,6 +140,33 @@ public static Person[] build(String[] people, ArrayList friends){ } } } - return zoo; //temporary return + return zoo; + } + public static ArrayList subgraph(String school, Person[] zoo){ + ArrayList schoolZoo = new ArrayList<>(); + for(int i=0; i< zoo.length; i++){ //go through all people in zoo----linear + if(zoo[i].school != null && zoo[i].school.equals(school)){ //if their school matches + Person tempPer = new Person(zoo[i].name, zoo[i].school, zoo[i].front); //copy zoo person + schoolZoo.add(tempPer); //add the person to the arrayList + } + } + for(int k=0; k Date: Sat, 1 Dec 2012 14:53:15 -0500 Subject: [PATCH 19/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index 69d780b..c461487 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -91,7 +91,7 @@ public static void main(String[] args) throws IOException { choice = getChoice(); } } - + //FIX NEEDED--- school is case insensitive public static Person[] build(String[] people, ArrayList friends){ Person[] zoo = new Person[people.length]; for(int i=0; i friends){ if(raw.charAt(raw.indexOf("|")+1)=='y'){ //attends school? school=raw.substring(raw.lastIndexOf('|')+1, raw.length()); //get the schoolname } - Person body = new Person(name, school, null); //create a new person + Person body = new Person(name, school, null, false, -1); //create a new person zoo[i]= body; //put him in the zoo } @@ -146,7 +146,7 @@ public static ArrayList subgraph(String school, Person[] zoo){ ArrayList schoolZoo = new ArrayList<>(); for(int i=0; i< zoo.length; i++){ //go through all people in zoo----linear if(zoo[i].school != null && zoo[i].school.equals(school)){ //if their school matches - Person tempPer = new Person(zoo[i].name, zoo[i].school, zoo[i].front); //copy zoo person + Person tempPer = new Person(zoo[i].name, zoo[i].school, zoo[i].front, false, i); //copy zoo person schoolZoo.add(tempPer); //add the person to the arrayList } } @@ -155,7 +155,7 @@ public static ArrayList subgraph(String school, Person[] zoo){ Friendex ptr = student.front; Friendex prev = null; while(ptr != null){ //go through the attached chain - if(zoo[ptr.friendNum].school != null && !zoo[ptr.friendNum].school.equals(school)){ + if(zoo[ptr.friendNum].school == null || !zoo[ptr.friendNum].school.equals(school)){ if(prev==null){ //first person doesn't attend target school student.front = ptr.next; }else{ @@ -167,6 +167,34 @@ public static ArrayList subgraph(String school, Person[] zoo){ ptr=ptr.next; } } + printSub(schoolZoo, zoo); return schoolZoo; } -} \ No newline at end of file + + public static void printSub(ArrayList schoolZoo, Person[] zoo){ + for(int i=0; i Date: Sat, 1 Dec 2012 14:54:03 -0500 Subject: [PATCH 20/33] Update friends/Person.java --- friends/Person.java | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/friends/Person.java b/friends/Person.java index e671841..f501309 100644 --- a/friends/Person.java +++ b/friends/Person.java @@ -1,28 +1,18 @@ package friends; -import java.util.*; - public class Person{ public String name; public String school; - public Person next; - public ArrayList friendList; + public Friendex front; + public boolean visited; + public int zooIndex; - public Person(String name, String school, Person next){ //ArrayList friendList + public Person(String name, String school, Friendex front, boolean visited, int zooIndex){ //ArrayList friendList this.name = name; this.school = school; - this.next = next; - //this.friendList = friendList; + this.front= front; + this.visited = visited; + this.zooIndex = zooIndex; } } - -//class friendList{ -// Person person; -// friendList next; -// -// public friendList(String name, String school, friendList next){ -// person = new Person(name, school); -// -// } -//} From b32cad0363fae3b1a3953995ad6160e1ad15624c Mon Sep 17 00:00:00 2001 From: stewsmith Date: Sat, 1 Dec 2012 14:55:20 -0500 Subject: [PATCH 21/33] Update friends/Graph_Methods.java --- friends/Graph_Methods.java | 98 ++++---------------------------------- 1 file changed, 9 insertions(+), 89 deletions(-) diff --git a/friends/Graph_Methods.java b/friends/Graph_Methods.java index 31e5683..439c94c 100644 --- a/friends/Graph_Methods.java +++ b/friends/Graph_Methods.java @@ -1,92 +1,12 @@ package friends; - -import java.io.*; -import java.util.*; - -class Term { - /** - * name of term. - */ - public String name; - - /** - * school of term. - */ - public String school; - - - - public Person[] build(String[] people, ArrayList friends){ - Person[] zoo = new Person[people.length]; - for(int i=0; i Date: Sat, 1 Dec 2012 17:30:28 -0500 Subject: [PATCH 22/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 45 ++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index c461487..edd08fe 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -1,8 +1,9 @@ package friends; import java.io.*; -import java.util.ArrayList; -import java.util.Scanner; +import java.util.*; +import java.lang.*; + public class Graph_Test { @@ -28,17 +29,12 @@ public static int getChoice() } - public static void shortest() - throws IOException { - System.out.print("Enter the name of the lonely boy => "); - String lone = stdin.nextLine(); - - } + public static void cliques() throws IOException { System.out.println("Enter the name of the school => "); - String x = stdin.nextLine(); + String school = stdin.nextLine(); } @@ -69,8 +65,8 @@ public static void main(String[] args) throws IOException { friendsBuk.add(line); } - Person[] graph = new Person[count]; - graph = build(personBuk, friendsBuk); //FUCK HOW DOES THIS SYNTAX WORK?!?! + Person[] zoo = new Person[count]; + zoo = build(personBuk, friendsBuk); //FUCK HOW DOES THIS SYNTAX WORK?!?! int choice = getChoice(); while (choice != QUIT) { @@ -80,9 +76,14 @@ public static void main(String[] args) throws IOException { switch (choice) { case STUDENTS: System.out.print("Enter the name of the school => "); - String sc = stdin.nextLine(); - subgraph(sc, graph); break; - case SHORT: shortest(); break; + String school = stdin.nextLine(); + subgraph(school, zoo); break; + case SHORT: + System.out.print("Enter the name of the starting person => "); + String start = stdin.nextLine(); + System.out.print("Enter the name of the starting person => "); + String target = stdin.nextLine(); + shortest(start, target, zoo); break; case CLIQUE: cliques(); break; case CONNECT: connectors(); break; //revise default: break; @@ -197,4 +198,20 @@ public static void printSub(ArrayList schoolZoo, Person[] zoo){ } } } + + public static void shortest(String start, String target, Person[] zoo)throws IOException { + Person perStart = null; + int startDex = -1; + for(int i=0; i newQ = new LinkedList(); + while (!newQ.isEmpty()){ + + + } + } + } } //end GraphTest class \ No newline at end of file From 1936fca2bd03a5360d2b8ea6e15987a66ad4531c Mon Sep 17 00:00:00 2001 From: stewsmith Date: Sun, 2 Dec 2012 20:16:31 -0500 Subject: [PATCH 23/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 76 ++++++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 19 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index edd08fe..f1d6bbd 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -2,6 +2,7 @@ import java.io.*; import java.util.*; +import java.util.Queue; import java.lang.*; @@ -27,9 +28,9 @@ public static int getChoice() System.out.print("\tEnter choice # => "); return (Integer.parseInt(br1.readLine())); } - - + + public static void cliques() throws IOException { @@ -67,7 +68,7 @@ public static void main(String[] args) throws IOException { Person[] zoo = new Person[count]; zoo = build(personBuk, friendsBuk); //FUCK HOW DOES THIS SYNTAX WORK?!?! - + int choice = getChoice(); while (choice != QUIT) { if (choice < 1 || choice > QUIT) { @@ -77,14 +78,17 @@ public static void main(String[] args) throws IOException { case STUDENTS: System.out.print("Enter the name of the school => "); String school = stdin.nextLine(); - subgraph(school, zoo); break; + subgraph(school, zoo, true); break; case SHORT: System.out.print("Enter the name of the starting person => "); String start = stdin.nextLine(); System.out.print("Enter the name of the starting person => "); String target = stdin.nextLine(); shortest(start, target, zoo); break; - case CLIQUE: cliques(); break; + case CLIQUE: + System.out.print("Enter the name of the school => "); + String sc = stdin.nextLine(); + cliques(sc, zoo); break; case CONNECT: connectors(); break; //revise default: break; } @@ -105,7 +109,7 @@ public static Person[] build(String[] people, ArrayList friends){ if(raw.charAt(raw.indexOf("|")+1)=='y'){ //attends school? school=raw.substring(raw.lastIndexOf('|')+1, raw.length()); //get the schoolname } - Person body = new Person(name, school, null, false, -1); //create a new person + Person body = new Person(name, school, null, false, -1,-1); //create a new person zoo[i]= body; //put him in the zoo } @@ -119,7 +123,7 @@ public static Person[] build(String[] people, ArrayList friends){ boolean secMatched =false; for(int k=0; k friends){ if(firstMatched && secMatched){ Friendex temp1 = zoo[firstDex.friendNum].front; //keep the chain that is already attached Friendex temp2 = zoo[secDex.friendNum].front; - + zoo[firstDex.friendNum].front = secDex; //update fronts zoo[secDex.friendNum].front = firstDex; - + firstDex.next = temp2; //attach old chains secDex.next = temp1; break; @@ -143,12 +147,16 @@ public static Person[] build(String[] people, ArrayList friends){ } return zoo; } - public static ArrayList subgraph(String school, Person[] zoo){ + public static ArrayList subgraph(String school, Person[] zoo, boolean printSub){ + ArrayList schoolZoo = new ArrayList<>(); - for(int i=0; i< zoo.length; i++){ //go through all people in zoo----linear + int schoolZoodex = 0; + for(int i=0; i< zoo.length; i++){ //go through all people in zoo----linear if(zoo[i].school != null && zoo[i].school.equals(school)){ //if their school matches - Person tempPer = new Person(zoo[i].name, zoo[i].school, zoo[i].front, false, i); //copy zoo person + zoo[i].schoolIndex=schoolZoodex; + Person tempPer = new Person(zoo[i].name, zoo[i].school, zoo[i].front, false, i,schoolZoodex); //copy zoo person schoolZoo.add(tempPer); //add the person to the arrayList + schoolZoodex++; } } for(int k=0; k subgraph(String school, Person[] zoo){ Friendex ptr = student.front; Friendex prev = null; while(ptr != null){ //go through the attached chain - if(zoo[ptr.friendNum].school == null || !zoo[ptr.friendNum].school.equals(school)){ + if(zoo[ptr.friendNum].schoolIndex <0){ if(prev==null){ //first person doesn't attend target school student.front = ptr.next; }else{ prev.next = ptr.next; //cut chains to non-attending person } }else{ + ptr.friendNum = zoo[ptr.friendNum].schoolIndex; prev=ptr; //student attends--- don't modify } ptr=ptr.next; } } - printSub(schoolZoo, zoo); + if(printSub){ + printSub(schoolZoo, zoo); + } + return schoolZoo; } - + public static void printSub(ArrayList schoolZoo, Person[] zoo){ for(int i=0; i schoolZoo, Person[] zoo){ } } } - + public static void shortest(String start, String target, Person[] zoo)throws IOException { Person perStart = null; int startDex = -1; @@ -207,11 +219,37 @@ public static void shortest(String start, String target, Person[] zoo)throws IOE perStart = zoo[i]; startDex = i; } - Queue newQ = new LinkedList(); - while (!newQ.isEmpty()){ - + + //Queue newQ = new Queue(); + Queue myq = new LinkedList(); } + } + + public static void cliques(String school, Person[] zoo){ + + ArrayList schoolZoo = subgraph(school, zoo, false); //creates subgraph with school + ArrayList answer = new ArrayList<>(); + + for(int i=0; i< schoolZoo.size(); i++){ //go through vertical array + Person vert = schoolZoo.get(i); + Queue newQ = new LinkedList(); + if(!vert.visited){ //the person has not been visited so he must be part of a new clique + ArrayList newClique = new ArrayList<>(); + newQ.add(vert); + while(!newQ.isEmpty()){ + Person justDQd = newQ.remove(); + justDQd.visited = true; //maybe mixing up schoolZoo and zoo visited + newClique.add(justDQd); + Friendex ptr = justDQd.front; + while(ptr != null){ //go through LL horizontally + newQ.add(schoolZoo.get(ptr.friendNum)); + ptr = ptr.next; + } + } + } + vert.visited = true; } + } } //end GraphTest class \ No newline at end of file From 8710bbf91e4d756ae1dca20f01ea6ee669741e76 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Sun, 2 Dec 2012 20:18:42 -0500 Subject: [PATCH 24/33] Update friends/Person.java --- friends/Person.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/friends/Person.java b/friends/Person.java index f501309..dd475fb 100644 --- a/friends/Person.java +++ b/friends/Person.java @@ -6,13 +6,15 @@ public class Person{ public Friendex front; public boolean visited; public int zooIndex; + public int schoolIndex; - public Person(String name, String school, Friendex front, boolean visited, int zooIndex){ //ArrayList friendList + public Person(String name, String school, Friendex front, boolean visited, int zooIndex, int schoolIndex){ //ArrayList friendList this.name = name; this.school = school; this.front= front; this.visited = visited; this.zooIndex = zooIndex; + this.schoolIndex = schoolIndex; } } From 5c0593a216664a69c26eb176154109627a611c52 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Sun, 2 Dec 2012 22:01:15 -0500 Subject: [PATCH 25/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 75 ++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index f1d6bbd..78c813b 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -82,14 +82,14 @@ public static void main(String[] args) throws IOException { case SHORT: System.out.print("Enter the name of the starting person => "); String start = stdin.nextLine(); - System.out.print("Enter the name of the starting person => "); + System.out.print("Enter the name of the target person => "); String target = stdin.nextLine(); shortest(start, target, zoo); break; case CLIQUE: System.out.print("Enter the name of the school => "); String sc = stdin.nextLine(); cliques(sc, zoo); break; - case CONNECT: connectors(); break; //revise + case CONNECT: connectors(); break; default: break; } } @@ -109,7 +109,7 @@ public static Person[] build(String[] people, ArrayList friends){ if(raw.charAt(raw.indexOf("|")+1)=='y'){ //attends school? school=raw.substring(raw.lastIndexOf('|')+1, raw.length()); //get the schoolname } - Person body = new Person(name, school, null, false, -1,-1); //create a new person + Person body = new Person(name, school, null, false, -1,-1,-1); //create a new person zoo[i]= body; //put him in the zoo } @@ -148,13 +148,13 @@ public static Person[] build(String[] people, ArrayList friends){ return zoo; } public static ArrayList subgraph(String school, Person[] zoo, boolean printSub){ - + ArrayList schoolZoo = new ArrayList<>(); int schoolZoodex = 0; for(int i=0; i< zoo.length; i++){ //go through all people in zoo----linear if(zoo[i].school != null && zoo[i].school.equals(school)){ //if their school matches zoo[i].schoolIndex=schoolZoodex; - Person tempPer = new Person(zoo[i].name, zoo[i].school, zoo[i].front, false, i,schoolZoodex); //copy zoo person + Person tempPer = new Person(zoo[i].name, zoo[i].school, zoo[i].front, false, i,schoolZoodex,-1); //copy zoo person schoolZoo.add(tempPer); //add the person to the arrayList schoolZoodex++; } @@ -213,29 +213,60 @@ public static void printSub(ArrayList schoolZoo, Person[] zoo){ public static void shortest(String start, String target, Person[] zoo)throws IOException { Person perStart = null; + Stack printStack = new Stack(); int startDex = -1; - for(int i=0; i newQ = new LinkedList(); + for(int i=0; i newQ = new Queue(); - Queue myq = new LinkedList(); - } - } + while (!newQ.isEmpty()){ //BFS queue build + zoo[newQ.peek()].visited = true; + Person parent = zoo[newQ.poll()]; + Friendex friendPtr = parent.front; + while (friendPtr!=null){ //move through friends + Person temp = zoo[friendPtr.friendNum]; //friend currently looking at + if (!zoo[friendPtr.friendNum].visited){ //unvisited friends + temp.zooIndex = friendPtr.friendNum; + temp.shortest = parent.zooIndex; //tells where the person came from + } + else{friendPtr = friendPtr.next;} //if friend has already been visited + if (target.equals(temp.name)){ // target is found + Person parentPtr = temp; + while (parentPtr.zooIndex != perStart.zooIndex){ //moves back and populates print stack + printStack.push(parentPtr); + parentPtr=zoo[parentPtr.shortest]; + } + }else {newQ.add(friendPtr.friendNum); //if temp is not the target put on BFS queue + friendPtr=friendPtr.next; + } + } + } + String answer = ""; + while (!printStack.isEmpty()){ + String name = printStack.pop().name; + answer += name + "--"; + } + answer = answer.substring(0,answer.length()-2); + } + public static void cliques(String school, Person[] zoo){ ArrayList schoolZoo = subgraph(school, zoo, false); //creates subgraph with school - ArrayList answer = new ArrayList<>(); + ArrayList> answer = new ArrayList<>(); for(int i=0; i< schoolZoo.size(); i++){ //go through vertical array Person vert = schoolZoo.get(i); Queue newQ = new LinkedList(); + ArrayList newClique = new ArrayList<>(); + boolean addClique = false; if(!vert.visited){ //the person has not been visited so he must be part of a new clique - ArrayList newClique = new ArrayList<>(); + addClique =true; newQ.add(vert); while(!newQ.isEmpty()){ Person justDQd = newQ.remove(); @@ -243,12 +274,26 @@ public static void cliques(String school, Person[] zoo){ newClique.add(justDQd); Friendex ptr = justDQd.front; while(ptr != null){ //go through LL horizontally - newQ.add(schoolZoo.get(ptr.friendNum)); + if(!schoolZoo.get(ptr.friendNum).visited){ + newQ.add(schoolZoo.get(ptr.friendNum)); + } ptr = ptr.next; } } } - vert.visited = true; + if(addClique){ + answer.add(newClique); + } + } + //Print out the cliques and members + for(int p=0; p clique = answer.get(p); + System.out.println("Clique " + (p+1) +":"); + for(int k=0; k Date: Mon, 3 Dec 2012 16:14:06 -0500 Subject: [PATCH 26/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 84 ++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index 78c813b..f381634 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -1,3 +1,6 @@ +/*Written by Stewart Smith and Jake Skelci for CS 112 Fall 2012*/ + + package friends; import java.io.*; @@ -29,21 +32,6 @@ public static int getChoice() return (Integer.parseInt(br1.readLine())); } - - - - public static void cliques() - throws IOException { - System.out.println("Enter the name of the school => "); - String school = stdin.nextLine(); - - } - - public static void connectors(){ - - - } - public static void main(String[] args) throws IOException { br1 = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the name of the friendship file => "); @@ -67,7 +55,7 @@ public static void main(String[] args) throws IOException { } Person[] zoo = new Person[count]; - zoo = build(personBuk, friendsBuk); //FUCK HOW DOES THIS SYNTAX WORK?!?! + zoo = build(personBuk, friendsBuk); int choice = getChoice(); while (choice != QUIT) { @@ -89,11 +77,14 @@ public static void main(String[] args) throws IOException { System.out.print("Enter the name of the school => "); String sc = stdin.nextLine(); cliques(sc, zoo); break; - case CONNECT: connectors(); break; + //case CONNECT: connectors(); break; default: break; } } choice = getChoice(); + for(int i=0; i printStack = new Stack(); int startDex = -1; Queue newQ = new LinkedList(); + boolean complete = false; //SS for(int i=0; i Date: Mon, 3 Dec 2012 17:55:20 -0500 Subject: [PATCH 27/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 74 +++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 17 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index f381634..2de5595 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -6,7 +6,7 @@ import java.io.*; import java.util.*; import java.util.Queue; -import java.lang.*; + @@ -66,28 +66,34 @@ public static void main(String[] args) throws IOException { case STUDENTS: System.out.print("Enter the name of the school => "); String school = stdin.nextLine(); - subgraph(school, zoo, true); break; + subgraph(school, zoo, true); + break; case SHORT: System.out.print("Enter the name of the starting person => "); String start = stdin.nextLine(); System.out.print("Enter the name of the target person => "); String target = stdin.nextLine(); - shortest(start, target, zoo); break; + shortest(start, target, zoo); + break; case CLIQUE: System.out.print("Enter the name of the school => "); String sc = stdin.nextLine(); - cliques(sc, zoo); break; - //case CONNECT: connectors(); break; + cliques(sc, zoo); + break; + case CONNECT: + connectors(zoo); + break; default: break; } } choice = getChoice(); for(int i=0; i friends){ Person[] zoo = new Person[people.length]; for(int i=0; i friends){ if(raw.charAt(raw.indexOf("|")+1)=='y'){ //attends school? school=raw.substring(raw.lastIndexOf('|')+1, raw.length()); //get the schoolname } - Person body = new Person(name, school, null, false, -1,-1,-1); //create a new person + Person body = new Person(name, school, null, false, -1,-1,-1,-1); //create a new person zoo[i]= body; //put him in the zoo } @@ -143,9 +149,9 @@ public static ArrayList subgraph(String school, Person[] zoo, boolean pr ArrayList schoolZoo = new ArrayList<>(); int schoolZoodex = 0; for(int i=0; i< zoo.length; i++){ //go through all people in zoo----linear - if(zoo[i].school != null && zoo[i].school.equals(school)){ //if their school matches + if(zoo[i].school != null && zoo[i].school.equalsIgnoreCase(school)){ //if their school matches zoo[i].schoolIndex=schoolZoodex; - Person tempPer = new Person(zoo[i].name, zoo[i].school, zoo[i].front, false, i,schoolZoodex,-1); //copy zoo person + Person tempPer = new Person(zoo[i].name, zoo[i].school, zoo[i].front, false, i,schoolZoodex,-1,-1); //copy zoo person schoolZoo.add(tempPer); //add the person to the arrayList schoolZoodex++; } @@ -205,18 +211,18 @@ public static void printSub(ArrayList schoolZoo, Person[] zoo){ public static void shortest(String start, String target, Person[] zoo)throws IOException { Person perStart = null; Stack printStack = new Stack(); - int startDex = -1; Queue newQ = new LinkedList(); boolean complete = false; //SS + for(int i=0; i dfsStack = new Stack(); + dfsStack.push(dfsStart); + dfsStart.visited=true; + while(!dfsStack.isEmpty()){ //stack allows forward movement when push and backward when popped + Person curr = dfsStack.peek(); + Friendex ptr = curr.front; + while(ptr != null){ //moves horizontally through friends + if(!zoo[ptr.friendNum].visited){ //get the first friend that isn't already visited + Person currFriend = zoo[ptr.friendNum]; + currFriend.visited =true; + dfsStack.push(currFriend); //moving forward in graph + break; + } + ptr = ptr.next; + } + if(ptr == null){ //no more friends + Person backwards = dfsStack.pop(); + } + + } + } + } + + } + } //end GraphTest class \ No newline at end of file From 14c06b5be1eba51a93d185f7db398267f71397c3 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Mon, 3 Dec 2012 17:57:27 -0500 Subject: [PATCH 28/33] Update friends/Person.java --- friends/Person.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/friends/Person.java b/friends/Person.java index dd475fb..1226630 100644 --- a/friends/Person.java +++ b/friends/Person.java @@ -7,14 +7,19 @@ public class Person{ public boolean visited; public int zooIndex; public int schoolIndex; + public int back; + public int dfs; - public Person(String name, String school, Friendex front, boolean visited, int zooIndex, int schoolIndex){ //ArrayList friendList + public Person(String name, String school, Friendex front, boolean visited, + int zooIndex, int schoolIndex, int back, int dfs){ //ArrayList friendList this.name = name; this.school = school; this.front= front; this.visited = visited; this.zooIndex = zooIndex; this.schoolIndex = schoolIndex; + this.back = back; + this.dfs = dfs; } } From 966604f5946a6aecac720f2679e6732aa56854a6 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Tue, 4 Dec 2012 22:15:52 -0500 Subject: [PATCH 29/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 84 ++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index 2de5595..93bb144 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -1,15 +1,11 @@ /*Written by Stewart Smith and Jake Skelci for CS 112 Fall 2012*/ - package friends; import java.io.*; import java.util.*; import java.util.Queue; - - - public class Graph_Test { static BufferedReader br1, br2; static Scanner stdin = new Scanner(System.in); @@ -54,8 +50,9 @@ public static void main(String[] args) throws IOException { friendsBuk.add(line); } + Hashtable hash = new Hashtable(); Person[] zoo = new Person[count]; - zoo = build(personBuk, friendsBuk); + zoo = build(personBuk, friendsBuk, hash); int choice = getChoice(); while (choice != QUIT) { @@ -73,7 +70,7 @@ public static void main(String[] args) throws IOException { String start = stdin.nextLine(); System.out.print("Enter the name of the target person => "); String target = stdin.nextLine(); - shortest(start, target, zoo); + shortest(start, target, zoo, hash); break; case CLIQUE: System.out.print("Enter the name of the school => "); @@ -92,9 +89,9 @@ public static void main(String[] args) throws IOException { zoo[i].back = -1; } } - } - - public static Person[] build(String[] people, ArrayList friends){ + } //end main method + + public static Person[] build(String[] people, ArrayList friends, Hashtable hash){ Person[] zoo = new Person[people.length]; for(int i=0; i friends){ } Person body = new Person(name, school, null, false, -1,-1,-1,-1); //create a new person zoo[i]= body; //put him in the zoo + hash.put(body.name, i); // } for(int j=0; j friends){ } } return zoo; - } + } //end build + + public static ArrayList subgraph(String school, Person[] zoo, boolean printSub){ ArrayList schoolZoo = new ArrayList<>(); @@ -177,9 +177,8 @@ public static ArrayList subgraph(String school, Person[] zoo, boolean pr if(printSub){ printSub(schoolZoo, zoo); } - return schoolZoo; - } + } //end subgraph public static void printSub(ArrayList schoolZoo, Person[] zoo){ for(int i=0; i schoolZoo, Person[] zoo){ ptr=ptr.next; } } - } + } //end printSub - public static void shortest(String start, String target, Person[] zoo)throws IOException { + public static void shortest(String start, String target, Person[] zoo, Hashtable hash)throws IOException { Person perStart = null; Stack printStack = new Stack(); Queue newQ = new LinkedList(); boolean complete = false; //SS - - for(int i=0; i dfsStack = new Stack(); dfsStack.push(dfsStart); - dfsStart.visited=true; while(!dfsStack.isEmpty()){ //stack allows forward movement when push and backward when popped Person curr = dfsStack.peek(); + if(!curr.visited){ + curr.dfs = count; + curr.back = count; + count++; + curr.visited = true; + } Friendex ptr = curr.front; while(ptr != null){ //moves horizontally through friends if(!zoo[ptr.friendNum].visited){ //get the first friend that isn't already visited Person currFriend = zoo[ptr.friendNum]; - currFriend.visited =true; dfsStack.push(currFriend); //moving forward in graph break; + }else{ + Person v = curr; + Person w = zoo[ptr.friendNum]; + v.back = Math.min(v.back, w.dfs); } ptr = ptr.next; } - if(ptr == null){ //no more friends - Person backwards = dfsStack.pop(); + if(ptr == null){ //end of the dfs line---- start going backwards + if(curr.dfs == dfsStart.dfs){ + break; //needs revision----reached the start + } + Person v = dfsStack.pop(); + Person w = dfsStack.peek(); + if(v.dfs>w.back){ + v.back = Math.min(v.back, w.dfs); + } } - } } } - } - } //end GraphTest class \ No newline at end of file From 57cbf49c5cf4a9c8bfebe7a1ee97bccac2992f22 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Tue, 4 Dec 2012 22:44:53 -0500 Subject: [PATCH 30/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index 93bb144..28c259b 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -79,6 +79,7 @@ public static void main(String[] args) throws IOException { break; case CONNECT: connectors(zoo); + System.out.println("Not done yet"); break; default: break; } @@ -330,7 +331,7 @@ private static void dfs(Person[] zoo){ Person currFriend = zoo[ptr.friendNum]; dfsStack.push(currFriend); //moving forward in graph break; - }else{ + }else{ //this is wrong suspicion Person v = curr; Person w = zoo[ptr.friendNum]; v.back = Math.min(v.back, w.dfs); @@ -343,8 +344,8 @@ private static void dfs(Person[] zoo){ } Person v = dfsStack.pop(); Person w = dfsStack.peek(); - if(v.dfs>w.back){ - v.back = Math.min(v.back, w.dfs); + if(v.dfs>w.back){ //or this is wrong + v.back = Math.min(v.back, w.back); } } } From 8eff1766d454b4ee1ed0f345491f1462c2581091 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Wed, 5 Dec 2012 15:56:31 -0500 Subject: [PATCH 31/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 355 ---------------------------------------- 1 file changed, 355 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index 28c259b..e69de29 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -1,355 +0,0 @@ -/*Written by Stewart Smith and Jake Skelci for CS 112 Fall 2012*/ - -package friends; - -import java.io.*; -import java.util.*; -import java.util.Queue; - -public class Graph_Test { - static BufferedReader br1, br2; - static Scanner stdin = new Scanner(System.in); - - public static final int STUDENTS = 1; - public static final int SHORT = 2; - public static final int CLIQUE = 3; - public static final int CONNECT = 4; - public static final int QUIT = 5; - - public static int getChoice() - throws IOException { - System.out.println(); - System.out.println(STUDENTS + ". Students at school"); - System.out.println(SHORT + ". Shortest intro chain"); - System.out.println(CLIQUE + ". Cliques at school"); - System.out.println(CONNECT + ". Connectors"); - System.out.println(QUIT + ". QUIT"); - System.out.print("\tEnter choice # => "); - return (Integer.parseInt(br1.readLine())); - } - - public static void main(String[] args) throws IOException { - br1 = new BufferedReader(new InputStreamReader(System.in)); - System.out.print("Enter the name of the friendship file => "); - br2 = new BufferedReader(new FileReader(br1.readLine())); - - int count = Integer.parseInt(br2.readLine())+1; //number of people - String[] personBuk = new String[count-1]; - - for(int i=0; i friendsBuk = new ArrayList(); - String line = br2.readLine(); - friendsBuk.add(line); - - while(line != null){ //put the friends line in an array - line = br2.readLine(); - friendsBuk.add(line); - } - - Hashtable hash = new Hashtable(); - Person[] zoo = new Person[count]; - zoo = build(personBuk, friendsBuk, hash); - - int choice = getChoice(); - while (choice != QUIT) { - if (choice < 1 || choice > QUIT) { - System.out.println("\tIncorrect choice " + choice); - } else { - switch (choice) { - case STUDENTS: - System.out.print("Enter the name of the school => "); - String school = stdin.nextLine(); - subgraph(school, zoo, true); - break; - case SHORT: - System.out.print("Enter the name of the starting person => "); - String start = stdin.nextLine(); - System.out.print("Enter the name of the target person => "); - String target = stdin.nextLine(); - shortest(start, target, zoo, hash); - break; - case CLIQUE: - System.out.print("Enter the name of the school => "); - String sc = stdin.nextLine(); - cliques(sc, zoo); - break; - case CONNECT: - connectors(zoo); - System.out.println("Not done yet"); - break; - default: break; - } - } - choice = getChoice(); - for(int i=0; i friends, Hashtable hash){ - Person[] zoo = new Person[people.length]; - for(int i=0; i subgraph(String school, Person[] zoo, boolean printSub){ - - ArrayList schoolZoo = new ArrayList<>(); - int schoolZoodex = 0; - for(int i=0; i< zoo.length; i++){ //go through all people in zoo----linear - if(zoo[i].school != null && zoo[i].school.equalsIgnoreCase(school)){ //if their school matches - zoo[i].schoolIndex=schoolZoodex; - Person tempPer = new Person(zoo[i].name, zoo[i].school, zoo[i].front, false, i,schoolZoodex,-1,-1); //copy zoo person - schoolZoo.add(tempPer); //add the person to the arrayList - schoolZoodex++; - } - } - for(int k=0; k schoolZoo, Person[] zoo){ - for(int i=0; i hash)throws IOException { - Person perStart = null; - Stack printStack = new Stack(); - Queue newQ = new LinkedList(); - boolean complete = false; //SS - - int i = hash.get(start); // finds the start person in zoo - perStart = zoo[i]; - perStart.zooIndex = i; - newQ.add(i); // add the start person to queue for BFS - - while (!newQ.isEmpty()){ //BFS queue build - if(complete) break; //SS - zoo[newQ.peek()].visited = true; - Person parent = zoo[newQ.poll()]; //dequeue front - Friendex friendPtr = parent.front; - while (friendPtr!=null){ //move horizontally through friends - Person temp = zoo[friendPtr.friendNum]; //friend currently looking at - if (!temp.visited){ //unvisited friends - temp.zooIndex = friendPtr.friendNum; - temp.back = parent.zooIndex; //tells where the person came from - } - else{ //if friend has already been visited - friendPtr = friendPtr.next; - continue; - } - if (target.equalsIgnoreCase(temp.name)){ // target is found - Person parentPtr = temp; - while (parentPtr.zooIndex != perStart.zooIndex){ //moves back and populates print stack - printStack.push(parentPtr); - parentPtr=zoo[parentPtr.back]; - } - printStack.push(perStart); // SS----adds last starting person to printStack - complete = true; //SS - break; // SS--- target found so break out of loop - }else {newQ.add(friendPtr.friendNum); //if temp is not the target put on BFS queue - friendPtr=friendPtr.next; - } - } - } - String answer = ""; - if(printStack.isEmpty()){ - System.out.println("No possible path"); - } - else{ - while (!printStack.isEmpty()){ - String name = printStack.pop().name; - answer += name + "--"; - } - answer = answer.substring(0,answer.length()-2); - System.out.println(answer); - } - } //end shortest - - - public static void cliques(String school, Person[] zoo){ - - ArrayList schoolZoo = subgraph(school, zoo, false); //creates subgraph with school - ArrayList> answer = new ArrayList<>(); - - for(int i=0; i< schoolZoo.size(); i++){ //go through vertical array - Person vert = schoolZoo.get(i); - Queue newQ = new LinkedList(); - ArrayList newClique = new ArrayList<>(); - boolean addClique = false; - if(!vert.visited){ //the person has not been visited so he must be part of a new clique - addClique =true; - newQ.add(vert); - while(!newQ.isEmpty()){ //BFS queue - Person justDQd = newQ.remove(); - justDQd.visited = true; - newClique.add(justDQd); - Friendex ptr = justDQd.front; - while(ptr != null){ //go through LL horizontally - if(!schoolZoo.get(ptr.friendNum).visited){ - newQ.add(schoolZoo.get(ptr.friendNum)); - } - ptr = ptr.next; - } - } - } - if(addClique){ - answer.add(newClique); - } - } - //Print out the cliques and members - for(int p=0; p clique = answer.get(p); - System.out.println("Clique " + (p+1) +":"); - for(int k=0; k dfsStack = new Stack(); - dfsStack.push(dfsStart); - while(!dfsStack.isEmpty()){ //stack allows forward movement when push and backward when popped - Person curr = dfsStack.peek(); - if(!curr.visited){ - curr.dfs = count; - curr.back = count; - count++; - curr.visited = true; - } - Friendex ptr = curr.front; - while(ptr != null){ //moves horizontally through friends - if(!zoo[ptr.friendNum].visited){ //get the first friend that isn't already visited - Person currFriend = zoo[ptr.friendNum]; - dfsStack.push(currFriend); //moving forward in graph - break; - }else{ //this is wrong suspicion - Person v = curr; - Person w = zoo[ptr.friendNum]; - v.back = Math.min(v.back, w.dfs); - } - ptr = ptr.next; - } - if(ptr == null){ //end of the dfs line---- start going backwards - if(curr.dfs == dfsStart.dfs){ - break; //needs revision----reached the start - } - Person v = dfsStack.pop(); - Person w = dfsStack.peek(); - if(v.dfs>w.back){ //or this is wrong - v.back = Math.min(v.back, w.back); - } - } - } - } - } - } -} //end GraphTest class \ No newline at end of file From 415b27142a367dfab6a0605376e3a00b8c9b99c7 Mon Sep 17 00:00:00 2001 From: stewsmith Date: Sat, 29 Dec 2012 19:41:02 -0500 Subject: [PATCH 32/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 384 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 384 insertions(+) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index e69de29..2a83be6 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -0,0 +1,384 @@ +/*Written by Stewart Smith and Jake Skelci for CS 112 Fall 2012*/ + +package friends; + +import java.io.*; +import java.util.*; +import java.util.Queue; + +public class Friends { + static BufferedReader br1, br2; + static Scanner stdin = new Scanner(System.in); + + public static final int STUDENTS = 1; + public static final int SHORT = 2; + public static final int CLIQUE = 3; + public static final int CONNECT = 4; + public static final int QUIT = 5; + + public static int getChoice() + throws IOException { + System.out.println(); + System.out.println(STUDENTS + ". Students at school"); + System.out.println(SHORT + ". Shortest intro chain"); + System.out.println(CLIQUE + ". Cliques at school"); + System.out.println(CONNECT + ". Connectors"); + System.out.println(QUIT + ". QUIT"); + System.out.print("\tEnter choice # => "); + return (Integer.parseInt(br1.readLine())); + } + + public static void main(String[] args) throws IOException { + br1 = new BufferedReader(new InputStreamReader(System.in)); + System.out.print("Enter the name of the friendship file => "); + br2 = new BufferedReader(new FileReader(br1.readLine())); + + int count = Integer.parseInt(br2.readLine())+1; //number of people + String[] personBuk = new String[count-1]; + + for(int i=0; i friendsBuk = new ArrayList(); + String line = br2.readLine(); + friendsBuk.add(line); + + while(line != null){ //put the friends line in an array + line = br2.readLine(); + friendsBuk.add(line); + } + + Hashtable hash = new Hashtable(); + Person[] zoo = new Person[count]; + zoo = build(personBuk, friendsBuk, hash); + + int choice = getChoice(); + while (choice != QUIT) { + if (choice < 1 || choice > QUIT) { + System.out.println("\tIncorrect choice " + choice); + } else { + switch (choice) { + case STUDENTS: + System.out.print("Enter the name of the school => "); + String school = stdin.nextLine(); + subgraph(school, zoo, true); + break; + case SHORT: + System.out.print("Enter the name of the starting person => "); + String start = stdin.nextLine(); + System.out.print("Enter the name of the target person => "); + String target = stdin.nextLine(); + shortest(start, target, zoo, hash); + break; + case CLIQUE: + System.out.print("Enter the name of the school => "); + String sc = stdin.nextLine(); + cliques(sc, zoo); + break; + case CONNECT: + connectors(zoo, count); + break; + default: break; + } + } + choice = getChoice(); + for(int i=0; i friends, Hashtable hash){ + Person[] zoo = new Person[people.length]; + for(int i=0; i subgraph(String school, Person[] zoo, boolean printSub){ + + ArrayList schoolZoo = new ArrayList<>(); + int schoolZoodex = 0; + for(int i=0; i< zoo.length; i++){ //go through all people in zoo----linear + if(zoo[i].school != null && zoo[i].school.equalsIgnoreCase(school)){ //if their school matches + zoo[i].schoolIndex=schoolZoodex; + + Person tempPer = new Person(zoo[i].name, zoo[i].school, zoo[i].front.copyList(), false, i,schoolZoodex,-1,-1); //copy zoo person + schoolZoo.add(tempPer); //add the person to the arrayList + schoolZoodex++; + } + } + for(int k=0; k schoolZoo){ + //boolean[] visited = new boolean[(schoolZoo.size())]; + for(int i=0; i hash)throws IOException { + Person perStart = null; + Stack printStack = new Stack(); + Queue newQ = new LinkedList(); + boolean complete = false; //SS + + int i = hash.get(start.toLowerCase()); // finds the start person in zoo + perStart = zoo[i]; + perStart.zooIndex = i; + newQ.add(i); // add the start person to queue for BFS + + while (!newQ.isEmpty()){ //BFS queue build + if(complete) break; //SS + zoo[newQ.peek()].visited = true; + Person parent = zoo[newQ.poll()]; //dequeue front + Friendex friendPtr = parent.front; + while (friendPtr!=null){ //move horizontally through friends + Person temp = zoo[friendPtr.friendNum]; //friend currently looking at + if (!temp.visited){ //unvisited friends + temp.zooIndex = friendPtr.friendNum; + temp.back = parent.zooIndex; //tells where the person came from + } + else{ //if friend has already been visited + friendPtr = friendPtr.next; + continue; + } + if (target.equalsIgnoreCase(temp.name)){ // target is found + Person parentPtr = temp; + while (parentPtr.zooIndex != perStart.zooIndex){ //moves back and populates print stack + printStack.push(parentPtr); + parentPtr=zoo[parentPtr.back]; + } + printStack.push(perStart); // SS----adds last starting person to printStack + complete = true; //SS + break; // SS--- target found so break out of loop + }else {newQ.add(friendPtr.friendNum); //if temp is not the target put on BFS queue + friendPtr=friendPtr.next; + } + } + } + String answer = ""; + if(printStack.isEmpty()){ + System.out.println("No possible path"); + } + else{ + while (!printStack.isEmpty()){ + String name = printStack.pop().name; + answer += name + "--"; + } + answer = answer.substring(0,answer.length()-2); + System.out.println(answer); + } + } //end shortest + + + public static void cliques(String school, Person[] zoo){ + + ArrayList schoolZoo = subgraph(school, zoo, false); //creates subgraph with school + ArrayList> answer = new ArrayList<>(); + + for(int i=0; i< schoolZoo.size(); i++){ //go through vertical array + Person vert = schoolZoo.get(i); + Queue newQ = new LinkedList(); + ArrayList newClique = new ArrayList<>(); + boolean addClique = false; + if(!vert.visited){ //the person has not been visited so he must be part of a new clique + addClique =true; + newQ.add(vert); + while(!newQ.isEmpty()){ //BFS queue + Person justDQd = newQ.remove(); + justDQd.visited = true; + newClique.add(justDQd); + Friendex ptr = justDQd.front; + while(ptr != null){ //go through LL horizontally + if(!schoolZoo.get(ptr.friendNum).visited){ + newQ.add(schoolZoo.get(ptr.friendNum)); + } + ptr = ptr.next; + } + } + } + if(addClique){ + answer.add(newClique); + } + } + //Print out the cliques and members + for(int p=0; p clique = answer.get(p); + System.out.println("Clique " + (p+1) +":"); + for(int k=0; k conn = new ArrayList(); + boolean[] conn = new boolean[zoo.length]; + + for(int i=0; i dfsStack = new Stack(); + dfsStack.push(dfsStart); + while(!dfsStack.isEmpty()){ //stack allows forward movement when push and backward when popped + Person curr = dfsStack.peek(); + if(!curr.visited){ + curr.dfs = count; + curr.back = count; + count++; + curr.visited = true; + } + Friendex ptr = curr.front; + while(ptr != null){ //moves horizontally through friends + if(!zoo[ptr.friendNum].visited){ //go to the friend that isn't already visited + Person currFriend = zoo[ptr.friendNum]; + dfsStack.push(currFriend); //moving forward in graph + break; + }else{ //neighbor is already visited + Person base = curr; + Person neigh = zoo[ptr.friendNum]; + base.back = Math.min(base.back, neigh.dfs); + } + ptr = ptr.next; + } + if(ptr == null){ //end of the dfs line---- start going backwards + if(curr.dfs == dfsStart.dfs){ + break; //needs revision----reached the start + } + Person neigh = dfsStack.pop(); // w = neigh + Person base = dfsStack.peek(); //v = base + if(base.dfs>neigh.back){ // condition for changing base.back + base.back = Math.min(base.back, neigh.back); + } + if(base.dfs <= neigh.back){ //CONNECTOR -- wrong: && base != dfsStart + if(base != dfsStart){ //normal connector + conn[base.zooIndex] = true; + }else{ //connector is at the start + Friendex stPtr = base.front; + while(stPtr != null){ //check for unvisited friends + if(!zoo[stPtr.friendNum].visited){ //if there is an unvisited friend + conn[base.zooIndex] = true; //then the start is a connector + break; + } + stPtr = stPtr.next; + } + } + + } + } + } + } + } + //give ans the all names of the connectors + String ans = ""; + for(int j=0; j Date: Sat, 29 Dec 2012 19:42:27 -0500 Subject: [PATCH 33/33] Update friends/Graph_Test.java --- friends/Graph_Test.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/friends/Graph_Test.java b/friends/Graph_Test.java index 2a83be6..2c5f617 100644 --- a/friends/Graph_Test.java +++ b/friends/Graph_Test.java @@ -1,5 +1,7 @@ -/*Written by Stewart Smith and Jake Skelci for CS 112 Fall 2012*/ - +/*Written by Stewart Smith and Jake Skelci for CS 112 Fall 2012 + * + * Uses BFS and DFS to find subgraphs, shortest paths, cliques, and connectors + * */ package friends; import java.io.*;