Learn R Programming

smallstuff (version 1.0.3)

graph_attr_from_df: Add Graph Attributes to a Graph from a Data Frame

Description

Add graph attributes to a graph from a data frame where each column represents an attribute. Note that only the first row of the data frame is used.

Usage

graph_attr_from_df(g, df)

Value

Graph g with the graph attributes in df added.

Arguments

g

the graph (an igraph object) to which the graph attributes should be added

df

data frame, or an object that can be converted to a data frame, where the first row contains a graph attribute in each column

Examples

Run this code
g=igraph::graph_from_literal(1-2,2-3:4,3-4:5:6,5-1)
df=data.frame(name="Test Graph",descr="A graph")
graph_attr_from_df(g,df)

Run the code above in your browser using DataLab