SlideShare a Scribd company logo
1 of 7
Project # 3/data (3).zip
friends6x6.csv
David,Frank
Cindy,Becky,Emily
Aaron
Becky,Cindy,Frank,Emily
Frank,David,Becky,Emily
Emily,Cindy,Becky,Frank
friends6x12.csv
David,Cindy,Becky,Frank,Emily
Cindy,David,Becky,Emily
Aaron,Becky,Frank,Emily
Becky,David,Cindy,Aaron,Frank,Emily
Frank,David,Aaron,Becky,Emily
Emily,David,Cindy,Aaron,Becky,Frank
friends26x26.csv
Aaron,Violet
Liam,Walter,Xander,Rolf,Hillary
Emily,Parker,Yuli
Gillian,Nina,Josh
Quinn,Marylyn
Terah,David
Simone,Marylyn,Rolf,Hillary
Irene,Parker,Yuli
Yuli,Xander,Violet,Emily,Irene
David,Terah
Cindy,Xander
Walter,Liam
Becky,Frank,Rolf
Xander,Cindy,Liam,Josh,Hillary,Yuli
Frank,Becky,Owen
Nina,Gillian
Josh,Xander,Gillian
Owen,Frank
Parker,Emily,Irene
Ursula
Kyle
Violet,Aaron,Yuli
Marylyn,Rolf,Simone,Quinn
Rolf,Becky,Liam,Marylyn,Simone
Hillary,Xander,Liam,Simone,Zera
Zera,Hillary
friends26x52.csv
Aaron,David,Violet,Parker
Liam,Walter,Xander,Rolf,Hillary,Irene,Owen,Gillian
Emily,Violet,Hillary,Parker,Quinn,Zera,Yuli
Gillian,Liam,Nina,Josh,Zera
Quinn,Kyle,Marylyn,Emily,Hillary,Owen
Terah,David,Yuli
Simone,David,Marylyn,Nina,Rolf,Hillary
Irene,Liam,Marylyn,Frank,Rolf,Parker,Yuli
Yuli,Terah,Xander,Violet,Emily,Irene,Zera
David,Aaron,Terah,Simone
Cindy,Xander
Walter,Liam,Rolf
Becky,Frank,Rolf
Xander,Cindy,Liam,Josh,Hillary,Yuli
Frank,Kyle,Becky,Irene,Owen
Nina,Simone,Gillian
Josh,Xander,Marylyn,Gillian
Owen,Liam,Frank,Quinn
Parker,Aaron,Emily,Irene
Ursula,Marylyn,Zera
Kyle,Frank,Quinn
Violet,Aaron,Emily,Yuli
Marylyn,Ursula,Rolf,Simone,Josh,Irene,Quinn
Rolf,Walter,Becky,Liam,Marylyn,Simone,Hillary,Irene
Hillary,Xander,Liam,Emily,Rolf,Simone,Quinn,Zera
Zera,Ursula,Emily,Hillary,Gillian,Yuli
Friendship.javaFriendship.javapackage edu.cwu.cs.cs302.friend
network;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.Random;
publicclassFriendship{
publicstaticvoid main(String[] args){
IFriendshipGraph network =newFriendshipGraph();
network.create("friends26x100.csv");
System.out.println(network);
List<String> names =newArrayList<String>(network.getPeople(
));
Random r =newRandom(302);
for(int i =0; i <10; i++){
String from = names.get(r.nextInt(names.size()));
String to = names.get(r.nextInt(names.size()));
Queue<String> relationship = network.getRelationship(from, to)
;
System.out
.println(from +" -- > "+ to +": "+" "+ relationship);
}
System.out.println();
if(network.allFriends()){
System.out.println("Everyone is friends!");
}else{
System.out.println("Some people have no friends.");
}
System.out.println();
System.out.println("Minimal Friendship Network");
System.out.println("--------------------------");
IFriendshipGraph graph = network.minimalGraph();
if(graph.isEmpty())
System.out.println("Cannot create a minimal graph.");
else
System.out.println(network.minimalGraph());
}
}
IFriendshipGraph.javaIFriendshipGraph.javapackage edu.cwu.cs
.cs302.friendnetwork;
import java.util.List;
import java.util.Queue;
publicinterfaceIFriendshipGraph{
/**
* Returns the names of all the people in the friendship graph
* @return a list of names
*/
publicList<String> getPeople();
/**
* Returns a list showing the connection between two people,
if one exists.
* @param person1 The name of the first person
* @param person2 The name of the second person
* @return An ordered list
*/
publicQueue<String> getRelationship(String person1,String per
son2);
/**
* Create the friendship graph from a CSV file
* @param filename The name of the CSV file
*/
publicvoid create(String filename);
/**
* Returns a multi-
line string containing the friendship information. For example:
*
* Aaron:
* Becky: Cindy Frank Emily
* Cindy: Becky Emily
* David: Frank
* Emily: Cindy Becky Frank
* Frank: David Becky Emily
*
* @return A string
*/
@Override
publicString toString();
/**
* Indicates if everyone is friends either directly or indirectly
* @return true if everyone is friends in some way
*/
publicboolean allFriends();
/**
* Create a minimal friendship graph. If some people are not
friends, either directly or indirectly, then return an empty graph.
* @return the minimal friendship graph
*/
publicIFriendshipGraph minimalGraph();
publicboolean isEmpty();
}
Project # 3/Friendship Network Project Details.docx
Friendship Network Project Details
In this project, you will create an application that determines
how two people are related via friends. The application reads in
a CSV file containing friendship information. The program will
then create a graph representing the friendship relationships and
use that graph to determine how two random people are related,
such as friend-of-a-friend-of-friend.
Example
Here is an example of the output from the program showing the
friendship information and the relationship information:
Aaron: Becky: Cindy Frank Emily Cindy: Becky Emily David:
Frank Emily: Cindy Becky Frank Frank: David Becky Emily
Cindy -- > Aaron: []David -- > David: [David]Emily -- > Aaron:
[]Cindy -- > Frank: [Cindy, Becky, Frank]Emily -- > Frank:
[Emily, Frank]Aaron -- > Aaron: [Aaron]Emily -- > Cindy:
[Emily, Cindy]Emily -- > David: [Emily, Frank, David]Becky --
> Aaron: []Cindy -- > David: [Cindy, Becky, Frank, David]
You can see that Cindy is a friend to David via Becky and
Frank, and David is a friend to himself, and that there is no way
that Becky and Aaron have no relationship.
Project Design
For this project, you are given a driver program
(Friendship.java) and an interface (IFriendshipGraph.java). You
are to create a class (FriendshipGraph.java) that implements the
interface.
There are three different levels for the program:
1. A class that provides an implementation
of getRelationship(a,b) which tells how two people are related
to each other through their friends using code from the
textbook. The methods allFriends() and minimalGraph() return
false and an empty graph, respectively. (Grade "C"-range)
2. A class that provides an implementation
of getRelationship(a,b) which tells how two people are related
to each other through their friends using code from the
textbook andimplements the
methods allFriends() and minimalGraph() using code from the
textbook. (Grade "B"-range)
3. The network code from the textbook is overkill for this
project as the code is designed for a digraph with weighted
edges, and the friendship graph is an undirected graph where all
edge weights are 1. The graph representation can be simplified.
One possible simplification is to represent the graph as a Map
of names and the set of the person's friends. Simplify the
textbook code and indicate in the Javadoc comments how you
simplified the textbook code. (Grade "A"-range)
Data
The data file contains the Java files and friendship CSV files.
data.zip

More Related Content

More from wkyra78

Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docxMeaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
wkyra78
 
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docxMBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
wkyra78
 
MediationNameAMUDate.docx
MediationNameAMUDate.docxMediationNameAMUDate.docx
MediationNameAMUDate.docx
wkyra78
 
Media Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docxMedia Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docx
wkyra78
 
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docxMBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
wkyra78
 
Media & Culture AssignmentFor this assignment, you are to develo.docx
Media & Culture AssignmentFor this assignment, you are to develo.docxMedia & Culture AssignmentFor this assignment, you are to develo.docx
Media & Culture AssignmentFor this assignment, you are to develo.docx
wkyra78
 
ME290 Global Engineering Professional Seminar Engine.docx
ME290 Global Engineering Professional Seminar Engine.docxME290 Global Engineering Professional Seminar Engine.docx
ME290 Global Engineering Professional Seminar Engine.docx
wkyra78
 
ME290 Global Engineering Professional Seminar Knowl.docx
ME290  Global Engineering Professional Seminar Knowl.docxME290  Global Engineering Professional Seminar Knowl.docx
ME290 Global Engineering Professional Seminar Knowl.docx
wkyra78
 
Meaning-Making Forum 1 (Week 4)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 1 (Week 4)Meaning-Making Forums 1-4 are thi.docxMeaning-Making Forum 1 (Week 4)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 1 (Week 4)Meaning-Making Forums 1-4 are thi.docx
wkyra78
 
MBA 705 Milestone Two Guidelines and Rubric Overview.docx
MBA 705 Milestone Two Guidelines and Rubric  Overview.docxMBA 705 Milestone Two Guidelines and Rubric  Overview.docx
MBA 705 Milestone Two Guidelines and Rubric Overview.docx
wkyra78
 
MBA 599 – Strategic Management Case Project This capsto.docx
MBA 599 – Strategic Management Case Project  This capsto.docxMBA 599 – Strategic Management Case Project  This capsto.docx
MBA 599 – Strategic Management Case Project This capsto.docx
wkyra78
 
MBA 6961, Project Management 1 Course Learning Outcomes .docx
MBA 6961, Project Management 1 Course Learning Outcomes .docxMBA 6961, Project Management 1 Course Learning Outcomes .docx
MBA 6961, Project Management 1 Course Learning Outcomes .docx
wkyra78
 
May 4 Answer SheetExercise 11. Parietal bone.2. Sphenoid .docx
May 4 Answer SheetExercise 11. Parietal bone.2. Sphenoid .docxMay 4 Answer SheetExercise 11. Parietal bone.2. Sphenoid .docx
May 4 Answer SheetExercise 11. Parietal bone.2. Sphenoid .docx
wkyra78
 

More from wkyra78 (20)

Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docxMeaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
 
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docxMBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
 
Medication Errors Led to Disastrous Outcomes1. Search th.docx
Medication Errors Led to Disastrous Outcomes1. Search th.docxMedication Errors Led to Disastrous Outcomes1. Search th.docx
Medication Errors Led to Disastrous Outcomes1. Search th.docx
 
Meet, call, Skype or Zoom with a retired athlete and interview himh.docx
Meet, call, Skype or Zoom with a retired athlete and interview himh.docxMeet, call, Skype or Zoom with a retired athlete and interview himh.docx
Meet, call, Skype or Zoom with a retired athlete and interview himh.docx
 
Medication Administration Make a list of the most common med.docx
Medication Administration Make a list of the most common med.docxMedication Administration Make a list of the most common med.docx
Medication Administration Make a list of the most common med.docx
 
media portfolio”about chapter 1 to 15 from the book  Ci.docx
media portfolio”about chapter 1 to 15 from the book  Ci.docxmedia portfolio”about chapter 1 to 15 from the book  Ci.docx
media portfolio”about chapter 1 to 15 from the book  Ci.docx
 
MediationNameAMUDate.docx
MediationNameAMUDate.docxMediationNameAMUDate.docx
MediationNameAMUDate.docx
 
Media coverage influences the publics perception of the crimina.docx
Media coverage influences the publics perception of the crimina.docxMedia coverage influences the publics perception of the crimina.docx
Media coverage influences the publics perception of the crimina.docx
 
Media Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docxMedia Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docx
 
Mayan gods and goddesses are very much a part of this text.  Their i.docx
Mayan gods and goddesses are very much a part of this text.  Their i.docxMayan gods and goddesses are very much a part of this text.  Their i.docx
Mayan gods and goddesses are very much a part of this text.  Their i.docx
 
Media and SocietyIn 1,100 words, complete the followingAn.docx
Media and SocietyIn 1,100 words, complete the followingAn.docxMedia and SocietyIn 1,100 words, complete the followingAn.docx
Media and SocietyIn 1,100 words, complete the followingAn.docx
 
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docxMBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
 
Media & Culture AssignmentFor this assignment, you are to develo.docx
Media & Culture AssignmentFor this assignment, you are to develo.docxMedia & Culture AssignmentFor this assignment, you are to develo.docx
Media & Culture AssignmentFor this assignment, you are to develo.docx
 
ME290 Global Engineering Professional Seminar Engine.docx
ME290 Global Engineering Professional Seminar Engine.docxME290 Global Engineering Professional Seminar Engine.docx
ME290 Global Engineering Professional Seminar Engine.docx
 
ME290 Global Engineering Professional Seminar Knowl.docx
ME290  Global Engineering Professional Seminar Knowl.docxME290  Global Engineering Professional Seminar Knowl.docx
ME290 Global Engineering Professional Seminar Knowl.docx
 
Meaning-Making Forum 1 (Week 4)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 1 (Week 4)Meaning-Making Forums 1-4 are thi.docxMeaning-Making Forum 1 (Week 4)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 1 (Week 4)Meaning-Making Forums 1-4 are thi.docx
 
MBA 705 Milestone Two Guidelines and Rubric Overview.docx
MBA 705 Milestone Two Guidelines and Rubric  Overview.docxMBA 705 Milestone Two Guidelines and Rubric  Overview.docx
MBA 705 Milestone Two Guidelines and Rubric Overview.docx
 
MBA 599 – Strategic Management Case Project This capsto.docx
MBA 599 – Strategic Management Case Project  This capsto.docxMBA 599 – Strategic Management Case Project  This capsto.docx
MBA 599 – Strategic Management Case Project This capsto.docx
 
MBA 6961, Project Management 1 Course Learning Outcomes .docx
MBA 6961, Project Management 1 Course Learning Outcomes .docxMBA 6961, Project Management 1 Course Learning Outcomes .docx
MBA 6961, Project Management 1 Course Learning Outcomes .docx
 
May 4 Answer SheetExercise 11. Parietal bone.2. Sphenoid .docx
May 4 Answer SheetExercise 11. Parietal bone.2. Sphenoid .docxMay 4 Answer SheetExercise 11. Parietal bone.2. Sphenoid .docx
May 4 Answer SheetExercise 11. Parietal bone.2. Sphenoid .docx
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 

Project # 3data (3).zipfriends6x6.csvDavid,FrankCindy.docx

  • 1. Project # 3/data (3).zip friends6x6.csv David,Frank Cindy,Becky,Emily Aaron Becky,Cindy,Frank,Emily Frank,David,Becky,Emily Emily,Cindy,Becky,Frank friends6x12.csv David,Cindy,Becky,Frank,Emily Cindy,David,Becky,Emily Aaron,Becky,Frank,Emily Becky,David,Cindy,Aaron,Frank,Emily Frank,David,Aaron,Becky,Emily Emily,David,Cindy,Aaron,Becky,Frank friends26x26.csv Aaron,Violet Liam,Walter,Xander,Rolf,Hillary Emily,Parker,Yuli Gillian,Nina,Josh Quinn,Marylyn Terah,David Simone,Marylyn,Rolf,Hillary Irene,Parker,Yuli Yuli,Xander,Violet,Emily,Irene David,Terah Cindy,Xander
  • 2. Walter,Liam Becky,Frank,Rolf Xander,Cindy,Liam,Josh,Hillary,Yuli Frank,Becky,Owen Nina,Gillian Josh,Xander,Gillian Owen,Frank Parker,Emily,Irene Ursula Kyle Violet,Aaron,Yuli Marylyn,Rolf,Simone,Quinn Rolf,Becky,Liam,Marylyn,Simone Hillary,Xander,Liam,Simone,Zera Zera,Hillary friends26x52.csv Aaron,David,Violet,Parker Liam,Walter,Xander,Rolf,Hillary,Irene,Owen,Gillian Emily,Violet,Hillary,Parker,Quinn,Zera,Yuli Gillian,Liam,Nina,Josh,Zera Quinn,Kyle,Marylyn,Emily,Hillary,Owen Terah,David,Yuli Simone,David,Marylyn,Nina,Rolf,Hillary Irene,Liam,Marylyn,Frank,Rolf,Parker,Yuli Yuli,Terah,Xander,Violet,Emily,Irene,Zera David,Aaron,Terah,Simone Cindy,Xander Walter,Liam,Rolf Becky,Frank,Rolf Xander,Cindy,Liam,Josh,Hillary,Yuli Frank,Kyle,Becky,Irene,Owen Nina,Simone,Gillian Josh,Xander,Marylyn,Gillian Owen,Liam,Frank,Quinn
  • 3. Parker,Aaron,Emily,Irene Ursula,Marylyn,Zera Kyle,Frank,Quinn Violet,Aaron,Emily,Yuli Marylyn,Ursula,Rolf,Simone,Josh,Irene,Quinn Rolf,Walter,Becky,Liam,Marylyn,Simone,Hillary,Irene Hillary,Xander,Liam,Emily,Rolf,Simone,Quinn,Zera Zera,Ursula,Emily,Hillary,Gillian,Yuli Friendship.javaFriendship.javapackage edu.cwu.cs.cs302.friend network; import java.util.ArrayList; import java.util.List; import java.util.Queue; import java.util.Random; publicclassFriendship{ publicstaticvoid main(String[] args){ IFriendshipGraph network =newFriendshipGraph(); network.create("friends26x100.csv"); System.out.println(network); List<String> names =newArrayList<String>(network.getPeople( )); Random r =newRandom(302); for(int i =0; i <10; i++){ String from = names.get(r.nextInt(names.size())); String to = names.get(r.nextInt(names.size())); Queue<String> relationship = network.getRelationship(from, to) ; System.out
  • 4. .println(from +" -- > "+ to +": "+" "+ relationship); } System.out.println(); if(network.allFriends()){ System.out.println("Everyone is friends!"); }else{ System.out.println("Some people have no friends."); } System.out.println(); System.out.println("Minimal Friendship Network"); System.out.println("--------------------------"); IFriendshipGraph graph = network.minimalGraph(); if(graph.isEmpty()) System.out.println("Cannot create a minimal graph."); else System.out.println(network.minimalGraph()); } } IFriendshipGraph.javaIFriendshipGraph.javapackage edu.cwu.cs .cs302.friendnetwork; import java.util.List; import java.util.Queue; publicinterfaceIFriendshipGraph{ /** * Returns the names of all the people in the friendship graph * @return a list of names */ publicList<String> getPeople();
  • 5. /** * Returns a list showing the connection between two people, if one exists. * @param person1 The name of the first person * @param person2 The name of the second person * @return An ordered list */ publicQueue<String> getRelationship(String person1,String per son2); /** * Create the friendship graph from a CSV file * @param filename The name of the CSV file */ publicvoid create(String filename); /** * Returns a multi- line string containing the friendship information. For example: * * Aaron: * Becky: Cindy Frank Emily * Cindy: Becky Emily * David: Frank * Emily: Cindy Becky Frank * Frank: David Becky Emily * * @return A string */ @Override publicString toString(); /** * Indicates if everyone is friends either directly or indirectly * @return true if everyone is friends in some way */
  • 6. publicboolean allFriends(); /** * Create a minimal friendship graph. If some people are not friends, either directly or indirectly, then return an empty graph. * @return the minimal friendship graph */ publicIFriendshipGraph minimalGraph(); publicboolean isEmpty(); } Project # 3/Friendship Network Project Details.docx Friendship Network Project Details In this project, you will create an application that determines how two people are related via friends. The application reads in a CSV file containing friendship information. The program will then create a graph representing the friendship relationships and use that graph to determine how two random people are related, such as friend-of-a-friend-of-friend. Example Here is an example of the output from the program showing the friendship information and the relationship information: Aaron: Becky: Cindy Frank Emily Cindy: Becky Emily David: Frank Emily: Cindy Becky Frank Frank: David Becky Emily Cindy -- > Aaron: []David -- > David: [David]Emily -- > Aaron: []Cindy -- > Frank: [Cindy, Becky, Frank]Emily -- > Frank: [Emily, Frank]Aaron -- > Aaron: [Aaron]Emily -- > Cindy: [Emily, Cindy]Emily -- > David: [Emily, Frank, David]Becky -- > Aaron: []Cindy -- > David: [Cindy, Becky, Frank, David] You can see that Cindy is a friend to David via Becky and Frank, and David is a friend to himself, and that there is no way that Becky and Aaron have no relationship. Project Design
  • 7. For this project, you are given a driver program (Friendship.java) and an interface (IFriendshipGraph.java). You are to create a class (FriendshipGraph.java) that implements the interface. There are three different levels for the program: 1. A class that provides an implementation of getRelationship(a,b) which tells how two people are related to each other through their friends using code from the textbook. The methods allFriends() and minimalGraph() return false and an empty graph, respectively. (Grade "C"-range) 2. A class that provides an implementation of getRelationship(a,b) which tells how two people are related to each other through their friends using code from the textbook andimplements the methods allFriends() and minimalGraph() using code from the textbook. (Grade "B"-range) 3. The network code from the textbook is overkill for this project as the code is designed for a digraph with weighted edges, and the friendship graph is an undirected graph where all edge weights are 1. The graph representation can be simplified. One possible simplification is to represent the graph as a Map of names and the set of the person's friends. Simplify the textbook code and indicate in the Javadoc comments how you simplified the textbook code. (Grade "A"-range) Data The data file contains the Java files and friendship CSV files. data.zip