Demo for analyzing the structural imbalance on a signed social network.

dwave-examples, updated 🕥 2022-01-21 22:59:35

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.


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

A. Local CPU Execution

bash python --cpu

B. D-Wave System Execution

bash python --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:

bash python --help


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.


Mapping Militant Organizations, Stanford University, last modified February 28, 2016,


0.1.1 2018-06-12 21:37:57

0.1.0 2018-06-07 23:21:16

0.0.2 2018-05-18 21:34:41

0.0.1 2018-05-14 22:16:59

D-Wave Systems Examples

D-Wave Ocean code examples

GitHub Repository

defense optimization intermediate social-network