Check for the existence of edge attributes in the graph
has_edge_attributes(x)
has_vertex_attributes(x)
has_vertex_attribute(x, attrname)
has_edge_attribute(x, attrname)
has_vertexnames(x)
has_loops(x)
has_isolates(x)
logical
Simple utility function that returns TRUE
if the graph has
edge attributes and FALSE
otherwise.
has_edge_attributes()
: Check whether a graph has edge attributes
has_vertex_attributes()
: Check whether a graph has vertex attributes (where
the attribute called "na" does not count, as that is only an internal attribute
by the network package)
has_vertex_attribute()
: Check whether a graph has a specific vertex attribute (where
the attribute called "na" does not count, as that is only an internal attribute
by the network package)
has_edge_attribute()
: Check whether a graph has a specific edge attribute
has_vertexnames()
: Check whether a graph has vertex names. The function merely checks
for the presence of the vertex attribute name
(for a network of
class igraph
) or vertex.names
(for a network of
class network
).
Note that the network
package tends to create vertex names by
default, even if they were not added as separate attributes.
In that case, the vertices are named as integers running from 1 to the
number of vertices. Of course, this function can not distinguish
whether these are names the researcher want to use as names, or purely
the result of the default behavior of the network
package (and
not meaningful names per se).
has_loops()
: Check whether a graph contains at least one loop (ie.
an edge from a vertex to itself). Also works on a matrix
.
has_isolates()
: Check whether a graph contains at least one isolate vertex.
Returns TRUE
or FAlsE
data(florentine, package = "snafun")
has_vertexnames(florentine$flobusiness) # TRUE
#> [1] TRUE
has_edge_attributes(florentine$flobusiness) # FALSE
#> [1] FALSE
has_edge_attributes(florentine$flomarriage) # TRUE
#> [1] TRUE
has_loops(florentine$flobusiness)
#> [1] FALSE
g <- igraph::graph( c(1,1,2,2,3,3,4,5))
has_loops(g)
#> [1] TRUE
m <- matrix(c(1, 0, 0, 0, 0, 1, 0, 1, 1), byrow = TRUE, ncol = 3)
has_loops(m) # TRUE
#> [1] TRUE
diag(m) <- 0
has_loops(m) # FALSE
#> [1] FALSE