GithubHelp home page GithubHelp logo

michaelmcroskey / facebook-fun Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 16.85 MB

Web app implementing Dijkstra's algorithm to visualize a Facebook friend network via D3.js, a Python server, and C++ executable

Makefile 0.68% C++ 4.41% Shell 0.26% Python 2.36% HTML 6.70% CSS 85.58%

facebook-fun's Introduction

Facebook Fun

Michael McRoskey (mmcrosk1), David Mellitt (dmellitt), Troy Prince (tprince)

CHECK OUT THE DEMO VIDEO!


Overview

Facebook Fun is a project which collects Facebook friend data from users to construct a visual display of an entire social network and determine the degrees of separation between two people. It runs on a local server via the SimpleHTTPServer module in Python and utilizes the D3.js data visualization framework. It also makes use of the Facebook Graph API to pull in friend data which it persistently stores.


Files

  1. server.py: This contains the script to process and handle server requests on localhost:9001. It loads index.html as the default page in a web browser.
  2. Makefile: Running the command make in this directory will properly compile dijkstras.cpp
  3. dikjstras.cpp: Performs the shortest path between nodes in graph
  4. edge.h: Header file for edge definitions
  5. node.h: Header file for nodes inside graph
  6. graph.h: Header file for graph definition
  7. test
    • makeFriends.sh: Makes the friend pairs that get inputted into testGraph.cpp
    • measure: Measures time and memory
    • testGraph: Executable for testGraph.cpp
    • Several input files
  8. www
    • index.html: HTML for web page
    • style.css: CSS styling for web page
    • graph.txt: The graph that gets plotted
    • graph-random.txt: A randomly generated graph file
  9. images
    • 3d-graph.png: example photo of graph
    • large-graph.png: example of a large graph in interface
  10. requirements.txt: Python environment requirements
  11. testGraph.cpp: Testbench for testing performance of data structure
  12. README.md
  13. CONTRIBUTORS.md

Usage

  1. Run $ make to build the executables.
  2. Run $ python server.py to run the Python server on localhost:9001
  3. In a web browser, navigate to http://localhost:9001/.
  4. Follow the instructions to sign in with Facebook, granting the app 'DS Final Project' access to your friends.

Note: Facebook's Graph API prevents us from pulling entire friend lists from a user. Instead, we can pull a list of friends who have also authorized the app. Thus, we have included a test list of friends:

NAME EMAIL PASSWORD
Michael [email protected] testing123
David [email protected] testing123
Troy [email protected] testing123
Shreya [email protected] testing123

You can login to Facebook with these people on www.facebook.com and verify their friends are correctly connected. However, the included graph.txt should already have a pre-built network based on test profiles of the London Data Structures section. You can also test out graph-random.txt for a graph of 150 randomly generated nodes (via testGraph.cpp).

Signing in as a user will append all those users friends (who have approved the app) to the graph.txt file. When another person signs in, it adds their friends, and so on. When enough people have added friends, a more connected graph will emerge.

  1. To check if two people are friends or how many degrees away they are from each other, type a first name into the 'Start Node' field and another first name into the 'End Node' field and click 'GO'.
  2. If a path exists, the webpage will generate a graph highlighting the edges between the specified nodes within a larger social network. Otherwise, it should output an error if:
  • The start and end are the same node
  • A user doesn't exist in the graph
  • Both users don't exist in the graph
  • In the event of a disconnected graph (no mutual friends), it will still display but obviously not display a connection between the disconnected nodes

Benchmarking

Using makeFriends.sh to create input files, we ran measure on testGraph.cpp, a more input friendly version of dijkstras.cpp. testGraph takes input as "source target" instead of the JSON file and creates an undirected edge.

People Elapsed Time Memory Usage
10 0.001411 0.835938
100 0.002383 0.878750
1000 0.010753 1.300781
10000 0.104035 5.682812
100000 1.045944 45.570312
1000000 11.411662 519.390625

Memory usage was proportional to nodes, which was expected. The elapsed time also seemed to grow proportional to nodes, although Dijkstra's is O(n^2 ). It helps that the algorithm stops once target is found.

Note: we deleted the largest two sample input files because of their size.

Benchmarked with 150 nodes!


Known Issues

As any good programming team would do, we wanted to highlight some known issues to prevent confusion about certain aspects of the program.

  1. Signing out - we have no function to sign out. Users must open a new Facebook tab and sign out through their interface.
  2. It really only works with a limited amount of users because of Facebook's API which restricts information sent to us--we are only allowed access to friends who have also authorized the app.
  3. As of now, the most inputs the program can take is 1000000 because that is the number of iterations dijkstras runs through before determining that two nodes are not connected (otherwise when two nodes are not connected there would be an infinite loop).
  4. We rely only on first names as node identifiers. In a market build, we would likely base nodes off of unique Facebook user IDs.

Contributions

Michael McRoskey: Python server and Javascript implementation

David Mellitt: Debugging, benchmarking

Troy Prince: Dijkstra's, graph management, testing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.