Compute a distance bin matrix from a distance matrix
In order for the
Knode functions to be run on a network, it is necessary to place the raw distances between each vertex pair into discreet distance bins, as the functions are unable to handle continuous distributions of distances. This is done automatically within the
Knode functions, but can also be done separately using
Numeric matrix, a distance matrix output by
Integer value, the desired number of bins across which the distances are to be split. If there are too few unique distances to fill each bin, then fewer bins are returned.
In order for the
Knode functions to be run, the vertex pair distances (as computed by
DistGraph) but be split into bins. This is done as part of the
Knode. However, this step is often slow for large networks and therefore the
BinGraph function is provided separately, in order to avoid repeat computation.
Each vertex pair is placed into a bin, either ranging from 1 to
nsteps, or from 1 to the number of unique distances.
FALSE, then the bin each vertex pair is placed into is directly proportional to the largest vertex pair distance. For example, if the distance between the pair is 25% of the largest distance and
100, then the vertex pair will be placed into bin
25. However, this can create problems when there are a small number of edges with especially large distances, as this can result in the majority of vertex pairs being placed into a small number of bins. This can reduce the effectiveness of the
Knode functions. Therefore, when
TRUE, the function attempts to fill each bin with an equal number of vertex pairs. If there are a large number of tied distances, then the bins may not be filled equally.
Integer matrix with the same dimensions as
Alex J. Cornish email@example.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# create network and calculate the distance matrix using the shortest paths measure g1 <- barabasi.game(6, directed=FALSE) plot(g1, layout=layout.fruchterman.reingold) D1 <- DistGraph(g1, dist.method="shortest.paths") # place the distances into distance bins BinGraph(D1, nsteps=100) # create network and calculate the distance matrix using diffusion kernel-based measure g2 <- erdos.renyi.game(6, p.or.m=0.5, directed=FALSE) g2 <- set.edge.attribute(g2, name="distance", value=runif(ecount(g2))) plot(g2, layout=layout.fruchterman.reingold) # place the distances into distance bins D2 <- DistGraph(g2, dist.method="diffusion", edge.attr="distance") BinGraph(D2, nsteps=100)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.