# On the theory of social balance

Hello Habr.
Today I want to tell you about the theory of cognitive balance of F. Haider .
The theory itself belongs to the class of theories of cognitive correspondence . Using this class of theories, one can try to mathematically describe social interactions, including in social networks.

The theory of cognitive balance says that a person in relation to the world around him is always either in a state of balance, or strives for it in all possible ways.

### Introduction

The original model names the name of the POX model and consisted of the following components:

1. P is a certain personality;
2. O - an object (including a person), in relation to which this person P - experiences some kind of relationship in the like / dislike format;
3. X is some other personality with respect to which P experiences some relations, and which itself also experiences some relations with respect to the object O, and P knows about it.

According to this theory, the ratio PO is also determined through the relations PX and OX as follows:
1. My friend’s friend is my friend.
2. A friend of my enemy is my enemy.
3. My friend’s enemy is my enemy.
4. The enemy of my enemy is my friend.

For example (from Wikipedia) if P loves O; P does not like X; P knows that X created O; can lead P according to this theory to the following possible conclusions:
1. X is not so bad
2. O - not so good
3. X is not an author of O.

Based on this model, we can build something of our own, gradually complicating the result.
So, suppose that:
1. We have 3 certain subjects: A, B and C.
2. All subjects have relations to each other, and these relations are mutual (this allows you to switch from a digraph to just a graph and simplify the initial model).

If we denote the subjects through the vertices of the graph, and the relations between them through the arcs, then we can consider the triad of the following form.

Now suppose that relationships can only be positive (+) and negative (-).
Then we can 8 possible states of our model.

There is a claim that the triad is harmonious, or stable, if the product of the signs of its connections is a positive number. That is, this is possible in the case when we have 3 positive connections, or two negative and one positive. That is, cases 1,4,6,7 are harmonious and stable, and cases 2, 3, 5, 8 are unstable.

In the form of a table, it will look as follows.

Unbalanced triads will tend to become balanced. Each of them has three possible scenarios. We get the so-called transition cube.

Moreover, the options for the development of a triad are equally probable.

If neutral bonds are added inside the triad, then the number of possible states will increase to 27. Moreover, 19 of them will be degenerate cases when not all relations are established. In this case, the missing connections will either not be involved at all or will strive for the balanced ones described above. Based on this information, the transition cube will look as follows.

That is, as in the first case, we get a binary tree of triads and transitions between them.
If the weights of the relations are not equal to each other, then the probabilities of the transition from one state to another will be different, and we can predict how the relations within the triad will change.

But isolated triads, like spherical horses in a vacuum, can only be on paper. In the real world, we have a more or less large collective, within which interactions are built on the same principle as inside triads. In this case, the balance of the group is determined by the balance of all its triads.

Of the two states of the groups, that is the more balanced, in which there are more balanced triads.

### Some formulas

To assess the balance of the group, you can enter a special index:

Where Tс is the number of balanced triads, To is the total number of triads.

Large connected subgroups with a high index of balance within groups can be represented as a separate enlarged subject, having relations with all other subjects.

There is a structural theorem which states that a large graph (a group of people, objects, relations between them) is in a balanced state if and only if the large group is divided into two small subgroups, inside which all connections are positive and the connections between groups are negative.

Indeed, if one subgroup is mentally divided into two connected ones with a large positive index, and the second subgroup left as is, then we get a classic balanced triad with one plus and two minuses. One can speculate on the topic that all subjects can have positive relations with each other, but the probability of such an outcome is 3 times lower than when divided into two competing subgroups (triad No. 1 and triad No. 4, 6, 7, respectively).

If we assume that there are N people in the group, then the number of possible relationships between them will be

Provided that our relations can be positive (+), negative (-) and neutral (0), the number of all possible states will be

where the total number triads will be

It should also be borne in mind that spontaneous transitions, ceteris paribus, are subject to the following rules.
1. The probability of a spontaneous transition of the relations (0) → (+) and (0) → (-) is close to unity.
2. The probability of a spontaneous transition of the relations (+) → (0), (-) → (0), (+) → (-), (-) → (+) is close to zero.
The first is due to the fact that in groups of people, usually everyone gets to know each other and one or another relationship is established. The second is explained by the fact that it is rather difficult to forget the person with whom you constantly communicate, or change the attitude towards him to the diametrically opposite.

Given these conditions, the following transition cube works for the triad.

The number of balanced triads in which a person takes part also affects spontaneous transitions. He seeks to go into a state in which the number of his balanced triads increases. In this case, to determine the likelihood of such a transition, a local link balance index is used. Obviously, one relationship cannot take part in all possible triads of the group. Therefore, for evaluation, only those triads are used in which this connection takes part.
Then we get

where Tс are balanced triads for a given connection, Tlock is the total number of triads for a given connection. The principle of evaluation is the same as for the whole group.

To complete the picture, you can add a smoother change in the relationship - not just positive, negative or zero, but also with some weight r enclosed in a certain interval. For example, in the range from -R to R, where R = 0.5; 1; 5; 10 ... In this case, you should specify the law by which these relations change. In a number of works, hysteresis is used for these purposes. Other works take into account the concept of social distance.

In this case, you can write a law according to which the relationship changes over time.

where G (r, R) = (1- (r / R)) ^ 2, and r (i, j) is the ratio between the ith and jth subjects.

### Examples

As a bonus, several animated gifs.

At the bottom of each image, a general balance index is displayed.

Even despite the small initial contradictions, all three are friendly.

Two are friends against the third.

For the four.

Everyone is friends with everyone.

The confrontation is 2 by 2.

As a result of complex gestures, three against one.

In order not to litter the article, the rest of the examples can be found in my album (for 5, 6, 10, and 25).

I want to warn that for a large number of people we got weighty GIFs under 10 MB.

And one more remark. The prototype program was written in C #, Graphviz was used for visualization .
Also, when calculating triads, one can take into account the state of neighbors of the second, third, and higher orders. Break into clusters, combine clusters into one big person. You can take into account the fact that we do not always know all the information about the relations between these or those subjects. Or those or other subjects themselves do not possess the completeness of information. We can also use some external influence, or assume that the arcs may have different weights, or one of the people has the resources to maintain stable good relations with some other person. Or their absence. You can consider an example of survival from an initially balanced group, and so on.

In the end, we can return to the original model and use the digraph, that is, the relations between the subjects become asymmetric. In this case, the number of arcs doubles, but the principles of calculation remain the same.

However, all this is already the subject of a much more serious study.