is.loop(graph, eids=E(graph))
has.multiple(graph)
is.multiple(graph, eids=E(graph))
count.multiple(graph, eids=E(graph))
has.multiple
returns a logical scalar.
is.loop
and is.multiple
return a logical
vector. count.multiple
returns a numeric vector.is.loop
decides whether the edges of the graph are loop edges.
has.multiple
decides whether the graph has any multiple edges. is.multiple
decides whether the edges of the graph are multiple
edges.
count.multiple
counts the multiplicity of each edge of a
graph.
Note that the semantics for is.multiple
and
count.multiple
is different. is.multiple
gives TRUE
for all occurences of a multiple edge except for one. Ie. if there are
three i-j
edges in the graph then is.multiple
returns
TRUE
for only two of them while count.multiple
returns
See the examples for getting rid of multiple edges while keeping their original multiplicity as an edge attribute.
simplify
to eliminate loop and multiple edges.# Loops
g <- graph( c(1,1,2,2,3,3,4,5) )
is.loop(g)
# Multiple edges
g <- barabasi.game(10, m=3, algorithm="bag")
has.multiple(g)
is.multiple(g)
count.multiple(g)
is.multiple(simplify(g))
all(count.multiple(simplify(g)) == 1)
# Direction of the edge is important
is.multiple(graph( c(1,2, 2,1) ))
is.multiple(graph( c(1,2, 2,1), dir=FALSE ))
# Remove multiple edges but keep multiplicity
g <- barabasi.game(10, m=3, algorithm="bag")
E(g)$weight <- count.multiple(g)
g <- simplify(g)
any(is.multiple(g))
E(g)$weight
Run the code above in your browser using DataLab