Git Product home page Git Product logo

structural-imbalance's Introduction

Open in GitHub Codespaces Linux/Mac/Windows build status

Structural Imbalance in Signed Social Networks

Social networks map relationships between people or organizations onto graphs, with the people/organizations as nodes and relationships as edges; for example, Facebook friends form a social network with friends represented as nodes with connecting edges. Signed social networks map both friendly and hostile relationships by setting the values of the edges between nodes with either plus ("+") or minus ("-") signs. Such networks are said to be structurally balanced when they can be clearly divided into two, with friendly relations (represented by positive-valued edges) in each faction, and hostile relations (negative-valued edges) between these factions.

The measure of structural imbalance or frustration for a signed social network is the minimum number of edges that violate this rule.

Three-person social network

Social theory suggests that increased frustration predicts social instability. In the context of militant organizations, this can result in increased violence.

This demo calculates and shows structural imbalance for social networks of militant organization based on data from the Stanford Militants Mapping Project.

Usage

To run the demo, execute one of the following two commands:

A. Local CPU Execution

python structural_imbalance.py --cpu

B. D-Wave System Execution

python structural_imbalance.py --qpu

Code Specifics

The demo fetches data from the Stanford Militants Mapping Project, calculates the networks, and saves a PNG graphic file of the imbalance network in the root directory of your copy of the demo repository.

Additional command line arguments are available to control the behavior of the demo, such as the region that is considered and whether to display a plot rather than saving a PNG file. Information about the command options is available via:

python structural_imbalance.py --help

License

The translation and solving code is released under the Apache License 2.0. See LICENSE file.

The dataset is used with permission from the Stanford Militants Mapping Project.

References

Mapping Militant Organizations, Stanford University, last modified February 28, 2016, http://web.stanford.edu/group/mappingmilitants/cgi-bin/.

structural-imbalance's People

Contributors

arcondello avatar bellert avatar hemantdwave avatar joelpasvolsky avatar m3ller avatar mcfarljm avatar randomir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

structural-imbalance's Issues

Use LeapHybridSampler

Currently, the sampler is hardcoded in the demo.

Either change to use LeapHybridSampler or allow the user to pick the sampler with the set of parameters.

In the demo, the results are plotted and saved. Display them instead.

@arcondello
@randomir

Remove old demo

#25 added a new implementation of the demo but did not go so far as to clean up the old one.

Map loader fails on Windows

Traceback (most recent call last):
  File "C:\Users\circleci\repo\demo.py", line 86, in <module>
    gssn = GlobalSignedSocialNetwork(qpu)
  File "C:\Users\circleci\repo\dwave_structural_imbalance_demo\interfaces.py", line 60, in __init__
    maps['Global'] = global_signed_social_network()
  File "C:\Users\circleci\repo\dwave_structural_imbalance_demo\mmp_network\loader.py", line 34, in global_signed_social_network
    next(data_iter)
  File "C:\Users\circleci\repo\python\tools\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 6347: character maps to <undefined>
ETraceback (most recent call last):
  File "C:\Users\circleci\repo\demo.py", line 86, in <module>
    gssn = GlobalSignedSocialNetwork(qpu)
  File "C:\Users\circleci\repo\dwave_structural_imbalance_demo\interfaces.py", line 60, in __init__
    maps['Global'] = global_signed_social_network()
  File "C:\Users\circleci\repo\dwave_structural_imbalance_demo\mmp_network\loader.py", line 34, in global_signed_social_network
    next(data_iter)
  File "C:\Users\circleci\repo\python\tools\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 6347: character maps to <undefined>

Restore commented out tests

a6a4a9f comments out two tests because they are unix-specific. If we wish to continue running these integration tests this way, we should fix and restore them.

CI failing due to "no embedding found"

The unit tests do pass for me locally with DW_2000Q_6 and Advantage. Is there a different QPU architecture that is being used by Circle CI? The fix may be to use a --region flag to define a smaller problem when running structural_imablance.py in the unit test.

Aerospace tag?

I'm having trouble seeing how the aerospace tag applies to this one.

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.