GithubHelp home page GithubHelp logo

friend_partitioning's Introduction

Friend (or not) partitioning

How to separate everyone from everyone that they hate with an algorithm


This solves a problem given by an assignment for design and analysis of algorithms which is as follows:

A group of people is planning an expedition. For safety, they decide to split into two groups; it does not matter how many people are in each group. Not all of them are good friends, and one reason for splitting is to separate all pairs that are not friendly to each other. Your goal is to design and implement an algorithm that, given the map of friendship relations between people in the group, would find a partition of people into two groups of friends, or say that it is impossible. Assume that the input is an n x n matrix M, where n is the number of people in the group and M(i,j) = 1 if i and j are friends, and 0 otherwise. Also, if i is friendly, then j is friendly to i. Your output should be the sequence of numbers corresponding to people assigned to the first group.


Included in this repository are two python files

The main python file is called groupSplit.py. Currently to use it you place your friend matrix inside the file and run python groupSplit.py / python3 groupSplit.py

The other python file called createFriendNet.py generates an array based on a few parameters that you can copy and paste into groupSplit.py to test functionality.

To run this python createFriendNet.py n x y / python3 createFriendNet.py n x y

Where n is the number of people in the network, and x, chance represent the proportion of values that will be 1 rather than 0. This can be read as an x in y chance.

For example python createFriendNet.py 10 9 10 creates a 10 x 10 friendship matrix where each person has a 9/10 or 90% chance of being any other persons friend.


todo

  • implement algorithm

  • optimize algorithm

  • generate pseudo code

  • add the ability to split into any number of groups

  • ████████████████████████████████████████████████████

  • wipe the last statement from your memory

friend_partitioning's People

Contributors

alexanderhurst avatar

Watchers

James Cloos avatar

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.