[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [igraph] R: vertex attributes in bipartite graphs for only one vertex ty

**From**: |
Michael Gastner |

**Subject**: |
[igraph] R: vertex attributes in bipartite graphs for only one vertex type |

**Date**: |
Mon, 25 Nov 2019 17:23:30 +0800 |

Suppose that the following bipartite graph represents directors
(vertices 1 to 5) and companies (vertices 6 and 7). An edge indicates
that a director on one end of an edge sits on the board of a company
on the other end of the edge.
g <- make_full_bipartite_graph(5, 2)
Also suppose that I have information about the directors' genders.
Next I would like to store the gender as a vertex attribute. The
following code works, but isn't very elegant because it creates a
meaningless gender attribute for the company vertices 6 and 7.
V(g)$gender <- c("F", "F", "M", "M", "M", NA, NA)
Semantically, this feels wrong because the company's gender isn't
missing data (NA), but companies don't have a gender in the first
place. Furthermore, if we had a larger data set, stuffing the
attribute vector with NAs feels wasteful.
Is there some way to create a vertex attribute that is only attached
to one vertex type in a bipartite graph (in this example the vertices
for which V(g)$type == FALSE)?
Michael

**[igraph] R: vertex attributes in bipartite graphs for only one vertex type**,
*Michael Gastner* **<=**