Skip to content

Basic social network-esque application built using Java that uses Dijkstra's algorithm, breadth first search, and shortest path

Notifications You must be signed in to change notification settings

JakeFerrero/social-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Social Network

A Java application that simulates a basic social network using Dijkstra's algorithm, breadth first search, and a shortest path algorithm. A user can check whether two people are fiends, whether one person is a mutual firend with another, whether two people are connected at all, and whether or not someone is popular based on the number of friends they have.

Usage

From the top-level directory:

java socialNetwork.SocialNetwork <input>

Where <input> contains names (seperated by newlines). Then a '$', then lines containing two names side-by-side (seperated by a space), representing a relationship between two people. For an example input file, see sampleSocialNetwork/sample.txt. The input file is needed in order to generate the actual "social network."

Once the application is started, a '$' will be present, letting the user know the app is ready for input. The following are valid queries:

  • isfriend personA personB
    • function: Is personA friends with personB?
    • output: yes / no<
  • mutual personA personB
    • function: Print out the mutual friends between personA and personB
    • output: all their names one per line, If there are no mutual acquaintances just print the $
  • relation personA personB
    • function: find the shortest sequence of friends between A and B ( the shortest path in the graph between nodes representing A and B)
    • output: print the names of all the friends on the path in order including A and B (at beginning and end), again one name per line
  • notconnected
    • function: Report how many pairs of people are not connected in the social network
    • For all pairs {A, B}in the social network, A is not connected to B if there is no path in the social network between A and B.
    • output: the number of such pairs (followed by a $).
  • popular
    • function: Report all the most popular people in the social network

About

Basic social network-esque application built using Java that uses Dijkstra's algorithm, breadth first search, and shortest path

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages