Let say that I have a dataframe (df) where it is supposed to contain friendship links between individuals. This way, a value (e.g. individual ID) in column A and a value in column B, indicates that individual A is friend (in relationship) with individual B. In fact, such a df can easily be converted to a graph (e.g. igraph).
Since the relationships are mutual, it is sufficient that we have A - B values.
However, I have such a large df where some of the rows also include B - A values as well (like directed graph, A is friend of B and B is friend of A, which is redundant) and the question is how to remove these redundant rows.
here is a very simple example:
df <- data.frame("A"= c(1, 10, 1, 1, 2, 2, 14, 4),
"B"= c(10, 1, 11, 12, 13, 14, 2, 15))
A B
1 10
10 1
1 11
1 12
2 13
2 14
14 2
4 15
After removing mutual references, the df should become:
A B
1 10
1 11
1 12
2 13
2 14
4 15