#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones",
"Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne",
"Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle",
"Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet",
"Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" )
label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones",
"Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne",
"Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle",
"Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet",
"Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" )
nodes<-data.frame(name,label)
from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane",
"Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty",
"Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams",
"Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero",
"Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler",
"Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino",
"Tom Thompson" )
to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese",
"Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero",
"George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver",
"Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet",
"Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero",
"Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero",
"Roger Rabbit" )
edges<-data.frame(from,to)
#Combine them in order to create the graph object
library(igraph)
library(dplyr)
gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes)
#Create the simple paths asp
asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero")
asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте sapply
с all_simple_paths
asp <- unlist(
sapply(
c("Steve Sweet", "Amy Adams"),
all_simple_paths,
graph = gph,
to = "Robert Zero"
),
recursive = FALSE
)
что дает
> asp #r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Steve Sweet1`
4/23 vertices, named, from 6674620:
[1] Steve Sweet Tom Thompson Roger Rabbit Robert Zero#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Steve Sweet2`
4/23 vertices, named, from 6674620:
[1] Steve Sweet Tom Thompson Victor Valentino Robert Zero#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Steve Sweet3`
5/23 vertices, named, from 6674620:
[1] Steve Sweet Ulrich Uxbridge Barry Beane Henry Handler
[5] Robert Zero#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Steve Sweet4`
5/23 vertices, named, from 6674620:
[1] Steve Sweet Ulrich Uxbridge Barry Beane Charlie Cheese
[5] Robert Zero#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Steve Sweet5`
5/23 vertices, named, from 6674620:
[1] Steve Sweet Ulrich Uxbridge Barry Beane Imogene Isler
[5] Robert Zero#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Steve Sweet6`
5/23 vertices, named, from 6674620:
[1] Steve Sweet Ulrich Uxbridge Barry Beane Peter Platteville
[5] Robert Zero#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Steve Sweet7`
5/23 vertices, named, from 6674620:
[1] Steve Sweet Ulrich Uxbridge Barry Beane Roger Rabbit
[5] Robert Zero#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Amy Adams1`
4/23 vertices, named, from 6674620:
[1] Amy Adams Barry Beane Henry Handler Robert Zero#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Amy Adams2`
4/23 vertices, named, from 6674620:
[1] Amy Adams Barry Beane Charlie Cheese Robert Zero#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Amy Adams3`
4/23 vertices, named, from 6674620:
[1] Amy Adams Barry Beane Imogene Isler Robert Zero#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Amy Adams4`
4/23 vertices, named, from 6674620:
[1] Amy Adams Barry Beane Peter Platteville Robert Zero#r #igraph
Вопрос:
У меня есть наборы данных узлов и ребер ниже, и я хотел бы знать, могу ли я запустить функцию простого пути для нескольких имен одновременно вместо одного за раз.
name<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) label<-c("Robert Zero", "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Norman Needle", "Oscar Oliver", "Peter Platteville", "Quincy Quebec", "Roger Rabbit", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge" ) nodes<-data.frame(name,label) from<-c("Robert Zero", "Amy Adams", "Barry Beane", "Barry Beane", "Barry Beane", "Julie Jones", "Karen Klein", "Imogene Isler", "David Dufresne", "Frank Flaherty", "Egbert English", "George Graham", "Molly McKee", "Molly McKee", "Amy Adams", "Peter Platteville", "Amy Adams", "Roger Rabbit", "Julie Jones", "Robert Zero", "Steve Sweet", "Tom Thompson", "Steve Sweet", "Ulrich Uxbridge", "Henry Handler", "Barry Beane", "Barry Beane", "Charlie Cheese", "Barry Beane", "Victor Valentino", "Tom Thompson" ) to<-c( "Amy Adams", "Barry Beane", "Henry Handler", "Julie Jones", "Charlie Cheese", "Karen Klein", "Lolly Landswright", "Robert Zero", "Frank Flaherty", "Robert Zero", "George Graham", "Robert Zero", "Norman Needle", "Julie Jones", "Oscar Oliver", "Robert Zero", "Quincy Quebec", "Robert Zero", "Molly McKee", "Steve Sweet", "Tom Thompson", "Victor Valentino", "Ulrich Uxbridge", "Barry Beane", "Robert Zero", "Imogene Isler", "Peter Platteville", "Robert Zero", "Roger Rabbit", "Robert Zero", "Roger Rabbit" ) edges<-data.frame(from,to) #Combine them in order to create the graph object library(igraph) library(dplyr) gph <- graph_from_data_frame(edges, directed=TRUE, vertices=nodes) #Create the simple paths asp asp <- all_simple_paths(gph, "Steve Sweet", "Robert Zero") asp2 <- all_simple_paths(gph, "Amy Adamas", "Robert Zero")
Вместо этого я хотел бы что-то вроде:
asp <- all_simple_paths(gph, c("Steve Sweet","Amy Adams"), "Robert Zero")
что мгновенно дало бы мне 12 путей
Ответ №1:
Попробуйте
sapply
сall_simple_paths
asp <- unlist( sapply( c("Steve Sweet", "Amy Adams"), all_simple_paths, graph = gph, to = "Robert Zero" ), recursive = FALSE )
что дает
Amy Adams5`
4/23 vertices, named, from 6674620:
[1] Amy Adams Barry Beane Roger Rabbit Robert Zero