0

Suppose a given directed graph G with N vertices and M edges.
How is it possible to create from the existing M connections of the graph G two subgraphs S_1 and S_2. These respective subgraphs each have half of the existing edges. Furthermore it is determined by randomness, whether an edge belongs to S_1 or S_2.

Example:

G <- erdos.renyi.game(5,p=0.5,directed = TRUE)
E(G)
> + 12/12 edges:
> [1] 1->5 2->1 4->1 5->1 1->2 3->2 5->2 1->3 3->5 5->3 2->4 3->4

Of the 12 existing edges should randomly M/2=6 edges be selected, which are representing the Edges in S_1. The remaining 6 edges provide the edges is of S_2.

digEmAll
  • 56,430
  • 9
  • 115
  • 140
Fulla
  • 17
  • 6
  • What should happen to the nodes connecting the edges of the subgraphs? Should be repeated in S_1 and S_2 ? e.g. `G = A->B->C`, `S_1 = A->B`, `S_2 = B->C` so, should node `B` present both in `S_1` and `S_2` ? – digEmAll Sep 07 '15 at 18:45
  • Yes, node B should be present in both. – Fulla Sep 07 '15 at 19:03
  • the Adjacency Matrix of S_1 and S_2 should have the dimensions N*N – Fulla Sep 07 '15 at 19:04

1 Answers1

2

Maybe I'm misunderstanding you:

library(igraph)
set.seed(1)     # for reproducible example
G <- erdos.renyi.game(5,p=0.5,directed = TRUE) 
E(G) 
# Edge sequence:
#           
# [1] 1 -> 5
# [2] 3 -> 1
# [3] 3 -> 2
# [4] 4 -> 2
# [5] 1 -> 3
# [6] 2 -> 3
# [7] 3 -> 5
# [8] 2 -> 4
# [9] 5 -> 4

eids <- sample(1:ecount(G), ecount(G)/2)
S1 <- subgraph.edges(G, eids)
S2 <- subgraph.edges(G, (1:ecount(G))[-eids])
E(S1)
# Edge sequence:
#           
# [1] 1 -> 5
# [2] 3 -> 2
# [3] 4 -> 2
# [4] 5 -> 4
E(S2)
# Edge sequence:
#           
# [1] 3 -> 1
# [2] 1 -> 3
# [3] 2 -> 3
# [4] 3 -> 5
# [5] 2 -> 4
jlhoward
  • 58,004
  • 7
  • 97
  • 140