# Make state graph for a six-state linear ordered character:
stategraph <- list(
n_vertices = 6,
n_arcs = 10,
n_states = 6,
single_states = c("0", "1", "2", "3", "4", "5"),
type = "ordered",
arcs = data.frame(
from = c("1", "0", "2", "1", "3", "2", "4", "3", "5", "4"),
to = c("0", "1", "1", "2", "2", "3", "3", "4", "4", "5"),
weight = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
),
vertices = data.frame(
label = c("0", "1", "2", "3", "4", "5"),
in_degree = c(1, 2, 2, 2, 2, 1),
out_degree = c(1, 2, 2, 2, 2, 1),
eccentricity = c(5, 4, 3, 3, 4, 5),
periphery = c(1, 0, 0, 0, 0, 1),
centre = c(0, 0, 1, 1, 0, 0)
),
radius = 3,
diameter = 5,
adjacency_matrix = matrix(
data = c(
0, 1, 0, 0, 0, 0,
1, 0, 1, 0, 0, 0,
0, 1, 0, 1, 0, 0,
0, 0, 1, 0, 1, 0,
0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 1, 0
),
ncol = 6,
byrow = TRUE,
dimnames = list(
c("0", "1", "2", "3", "4", "5"),
c("0", "1", "2", "3", "4", "5")
)
),
directed = FALSE,
includes_polymorphisms = FALSE,
polymorphism_costs = "additive",
polymorphism_geometry = "simplex",
polymorphism_distance = "euclidean",
includes_uncertainties = FALSE,
pruned = FALSE,
dollo_penalty = 999,
base_age = 1,
weight = 1
)
# Set calss as stateGraph:
class(x = stategraph) <- "stateGraph"
# View state graph:
stategraph
# Convert state graph to a costmatrix:
costmatrix <- convert_stategraph_to_costmatrix(stategraph = stategraph)
# Show costmatrix reflects linear ordered costs:
costmatrix$costmatrix
Run the code above in your browser using DataLab