EdgelistFill: Ensure an edgelist has all dyads and a column of weights.

Description Usage Arguments Details Value Author(s) References Examples

View source: R/EdgelistFill.R

Description

Given a matrix or data.frame edgelist, fill in all possible edges not already listed with a weight of 0 or the value of fillBlanksWith.

Usage

1
  EdgelistFill(elist, fillBlanksWith = 0, nodelist)

Arguments

elist

data.frame or matrix, see 'Details' for formatting assumptions.

fillBlanksWith

numeric, default weight for edges not already listed in elist.

nodelist

character, optional list of node names.

Details

The elist can be either a data.frame or a matrix with either 2 or 3 columns. Each row is an edge. The first column lists the node the edge is 'from' and the second column lists the node the edge is 'to'. If there is a third column, it lists the weight of the edge.

Value

data.frame, full list of all possible edges with weights for each in third column.

Author(s)

Stephen R. Haptonstahl srh@haptonstahl.org

References

https://github.com/shaptonstahl/

Examples

1
2
3
4
5
6
7
8
g <- erdos.renyi.game(10, 2/10)
EdgelistFill(get.edgelist(g))
EdgelistFill(get.edgelist(g), nodelist=1:10)

E(g)$weight <- runif(ecount(g))
el <- cbind(get.edgelist(g), E(g)$weight)
EdgelistFill(el)
EdgelistFill(el, nodelist=1:10)

Example output

Loading required package: igraph

Attaching package:igraphThe following objects are masked frompackage:stats:

    decompose, spectrum

The following object is masked frompackage:base:

    union

Loading required package: Rcpp
    fromnode tonode weight
1          1      1      0
2          1      2      0
3          1      3      1
4          1      4      0
5          1      5      0
6          1      6      0
7          1      7      0
8          1      8      1
9          1      9      0
10         1     10      0
11         2      1      0
12         2      2      0
13         2      3      0
14         2      4      0
15         2      5      1
16         2      6      0
17         2      7      0
18         2      8      0
19         2      9      0
20         2     10      1
21         3      1      0
22         3      2      0
23         3      3      0
24         3      4      0
25         3      5      0
26         3      6      1
27         3      7      0
28         3      8      1
29         3      9      0
30         3     10      0
31         4      1      0
32         4      2      0
33         4      3      0
34         4      4      0
35         4      5      1
36         4      6      0
37         4      7      0
38         4      8      0
39         4      9      0
40         4     10      0
41         5      1      0
42         5      2      0
43         5      3      0
44         5      4      0
45         5      5      0
46         5      6      0
47         5      7      0
48         5      8      1
49         5      9      0
50         5     10      0
51         6      1      0
52         6      2      0
53         6      3      0
54         6      4      0
55         6      5      0
56         6      6      0
57         6      7      0
58         6      8      0
59         6      9      0
60         6     10      0
61         7      1      0
62         7      2      0
63         7      3      0
64         7      4      0
65         7      5      0
66         7      6      0
67         7      7      0
68         7      8      0
69         7      9      1
70         7     10      0
71         8      1      0
72         8      2      0
73         8      3      0
74         8      4      0
75         8      5      0
76         8      6      0
77         8      7      0
78         8      8      0
79         8      9      0
80         8     10      0
81         9      1      0
82         9      2      0
83         9      3      0
84         9      4      0
85         9      5      0
86         9      6      0
87         9      7      0
88         9      8      0
89         9      9      0
90         9     10      1
91        10      1      0
92        10      2      0
93        10      3      0
94        10      4      0
95        10      5      0
96        10      6      0
97        10      7      0
98        10      8      0
99        10      9      0
100       10     10      0
    fromnode tonode weight
1          1      1      0
2          1      2      0
3          1      3      1
4          1      4      0
5          1      5      0
6          1      6      0
7          1      7      0
8          1      8      1
9          1      9      0
10         1     10      0
11         2      1      0
12         2      2      0
13         2      3      0
14         2      4      0
15         2      5      1
16         2      6      0
17         2      7      0
18         2      8      0
19         2      9      0
20         2     10      1
21         3      1      0
22         3      2      0
23         3      3      0
24         3      4      0
25         3      5      0
26         3      6      1
27         3      7      0
28         3      8      1
29         3      9      0
30         3     10      0
31         4      1      0
32         4      2      0
33         4      3      0
34         4      4      0
35         4      5      1
36         4      6      0
37         4      7      0
38         4      8      0
39         4      9      0
40         4     10      0
41         5      1      0
42         5      2      0
43         5      3      0
44         5      4      0
45         5      5      0
46         5      6      0
47         5      7      0
48         5      8      1
49         5      9      0
50         5     10      0
51         6      1      0
52         6      2      0
53         6      3      0
54         6      4      0
55         6      5      0
56         6      6      0
57         6      7      0
58         6      8      0
59         6      9      0
60         6     10      0
61         7      1      0
62         7      2      0
63         7      3      0
64         7      4      0
65         7      5      0
66         7      6      0
67         7      7      0
68         7      8      0
69         7      9      1
70         7     10      0
71         8      1      0
72         8      2      0
73         8      3      0
74         8      4      0
75         8      5      0
76         8      6      0
77         8      7      0
78         8      8      0
79         8      9      0
80         8     10      0
81         9      1      0
82         9      2      0
83         9      3      0
84         9      4      0
85         9      5      0
86         9      6      0
87         9      7      0
88         9      8      0
89         9      9      0
90         9     10      1
91        10      1      0
92        10      2      0
93        10      3      0
94        10      4      0
95        10      5      0
96        10      6      0
97        10      7      0
98        10      8      0
99        10      9      0
100       10     10      0
    fromnode tonode     weight
1          1      1 0.00000000
2          1      2 0.00000000
3          1      3 0.70840076
4          1      4 0.00000000
5          1      5 0.00000000
6          1      6 0.00000000
7          1      7 0.00000000
8          1      8 0.27267918
9          1      9 0.00000000
10         1     10 0.00000000
11         2      1 0.00000000
12         2      2 0.00000000
13         2      3 0.00000000
14         2      4 0.00000000
15         2      5 0.55328424
16         2      6 0.00000000
17         2      7 0.00000000
18         2      8 0.00000000
19         2      9 0.00000000
20         2     10 0.62035742
21         3      1 0.00000000
22         3      2 0.00000000
23         3      3 0.00000000
24         3      4 0.00000000
25         3      5 0.00000000
26         3      6 0.20929305
27         3      7 0.00000000
28         3      8 0.69755197
29         3      9 0.00000000
30         3     10 0.00000000
31         4      1 0.00000000
32         4      2 0.00000000
33         4      3 0.00000000
34         4      4 0.00000000
35         4      5 0.02630632
36         4      6 0.00000000
37         4      7 0.00000000
38         4      8 0.00000000
39         4      9 0.00000000
40         4     10 0.00000000
41         5      1 0.00000000
42         5      2 0.00000000
43         5      3 0.00000000
44         5      4 0.00000000
45         5      5 0.00000000
46         5      6 0.00000000
47         5      7 0.00000000
48         5      8 0.34808191
49         5      9 0.00000000
50         5     10 0.00000000
51         6      1 0.00000000
52         6      2 0.00000000
53         6      3 0.00000000
54         6      4 0.00000000
55         6      5 0.00000000
56         6      6 0.00000000
57         6      7 0.00000000
58         6      8 0.00000000
59         6      9 0.00000000
60         6     10 0.00000000
61         7      1 0.00000000
62         7      2 0.00000000
63         7      3 0.00000000
64         7      4 0.00000000
65         7      5 0.00000000
66         7      6 0.00000000
67         7      7 0.00000000
68         7      8 0.00000000
69         7      9 0.81578597
70         7     10 0.00000000
71         8      1 0.00000000
72         8      2 0.00000000
73         8      3 0.00000000
74         8      4 0.00000000
75         8      5 0.00000000
76         8      6 0.00000000
77         8      7 0.00000000
78         8      8 0.00000000
79         8      9 0.00000000
80         8     10 0.00000000
81         9      1 0.00000000
82         9      2 0.00000000
83         9      3 0.00000000
84         9      4 0.00000000
85         9      5 0.00000000
86         9      6 0.00000000
87         9      7 0.00000000
88         9      8 0.00000000
89         9      9 0.00000000
90         9     10 0.31717559
91        10      1 0.00000000
92        10      2 0.00000000
93        10      3 0.00000000
94        10      4 0.00000000
95        10      5 0.00000000
96        10      6 0.00000000
97        10      7 0.00000000
98        10      8 0.00000000
99        10      9 0.00000000
100       10     10 0.00000000
    fromnode tonode     weight
1          1      1 0.00000000
2          1      2 0.00000000
3          1      3 0.70840076
4          1      4 0.00000000
5          1      5 0.00000000
6          1      6 0.00000000
7          1      7 0.00000000
8          1      8 0.27267918
9          1      9 0.00000000
10         1     10 0.00000000
11         2      1 0.00000000
12         2      2 0.00000000
13         2      3 0.00000000
14         2      4 0.00000000
15         2      5 0.55328424
16         2      6 0.00000000
17         2      7 0.00000000
18         2      8 0.00000000
19         2      9 0.00000000
20         2     10 0.62035742
21         3      1 0.00000000
22         3      2 0.00000000
23         3      3 0.00000000
24         3      4 0.00000000
25         3      5 0.00000000
26         3      6 0.20929305
27         3      7 0.00000000
28         3      8 0.69755197
29         3      9 0.00000000
30         3     10 0.00000000
31         4      1 0.00000000
32         4      2 0.00000000
33         4      3 0.00000000
34         4      4 0.00000000
35         4      5 0.02630632
36         4      6 0.00000000
37         4      7 0.00000000
38         4      8 0.00000000
39         4      9 0.00000000
40         4     10 0.00000000
41         5      1 0.00000000
42         5      2 0.00000000
43         5      3 0.00000000
44         5      4 0.00000000
45         5      5 0.00000000
46         5      6 0.00000000
47         5      7 0.00000000
48         5      8 0.34808191
49         5      9 0.00000000
50         5     10 0.00000000
51         6      1 0.00000000
52         6      2 0.00000000
53         6      3 0.00000000
54         6      4 0.00000000
55         6      5 0.00000000
56         6      6 0.00000000
57         6      7 0.00000000
58         6      8 0.00000000
59         6      9 0.00000000
60         6     10 0.00000000
61         7      1 0.00000000
62         7      2 0.00000000
63         7      3 0.00000000
64         7      4 0.00000000
65         7      5 0.00000000
66         7      6 0.00000000
67         7      7 0.00000000
68         7      8 0.00000000
69         7      9 0.81578597
70         7     10 0.00000000
71         8      1 0.00000000
72         8      2 0.00000000
73         8      3 0.00000000
74         8      4 0.00000000
75         8      5 0.00000000
76         8      6 0.00000000
77         8      7 0.00000000
78         8      8 0.00000000
79         8      9 0.00000000
80         8     10 0.00000000
81         9      1 0.00000000
82         9      2 0.00000000
83         9      3 0.00000000
84         9      4 0.00000000
85         9      5 0.00000000
86         9      6 0.00000000
87         9      7 0.00000000
88         9      8 0.00000000
89         9      9 0.00000000
90         9     10 0.31717559
91        10      1 0.00000000
92        10      2 0.00000000
93        10      3 0.00000000
94        10      4 0.00000000
95        10      5 0.00000000
96        10      6 0.00000000
97        10      7 0.00000000
98        10      8 0.00000000
99        10      9 0.00000000
100       10     10 0.00000000

dils documentation built on May 2, 2019, 8:28 a.m.