For a given edge list, construct a nested list (i.e., dictionary of dictionaries in Python syntax) of the neighbors of each node in the edge list stratified by type. This reference object can be used instead of the edge list in subsequent metapaths functions, since searching the edge list to recompute neighbors each time would have O(n) complexity, while searching a pre-computed neighbors dictionary requires a fixed amount of time.

get_neighbor_list(
  edge_list,
  file_path = NULL,
  intermediate_file_path = NULL,
  verbose = F
)

Arguments

edge_list

Edge list as a data.table which must contain the following columns:

Origin

IDs of the origin nodes for each edge.

Destination

IDs of the destination nodes for each edge.

OriginType

Types of the origin node for each edge.

DestinationType

Types of the destination node for each edge.

EdgeType

Types of each edge.

file_path

File path to save final data.table reference object. If no path is specified, the reference object is not saved.

intermediate_file_path

File path to save intermediate list of lists reference object. If no path is specified, the intermediate reference object is not saved.

verbose

Should node types and total node count be printed to the console?

Value

Neighbors reference object as a data.table

Examples

mtcars_neighbor_list = get_neighbor_list(mtcars_edge_list, verbose = T)
#> Node Types:
#> - Five
#> - Three
#> - Four
#> 
#> Total Node Count: 32
head(mtcars_neighbor_list)
#>                  Node                                    Five
#> 1:        AMC Javelin                                      NA
#> 2: Cadillac Fleetwood              Maserati Bora,Ferrari Dino
#> 3:         Camaro Z28                           Porsche 914-2
#> 4:  Chrysler Imperial                           Maserati Bora
#> 5:         Datsun 710                                      NA
#> 6:   Dodge Challenger Ferrari Dino,Maserati Bora,Lotus Europa
#>                                                          Three
#> 1:                                                 Merc 450SLC
#> 2: Merc 450SLC,Lincoln Continental,Dodge Challenger,Merc 450SL
#> 3:                                       Camaro Z28,Merc 450SE
#> 4:                                            Dodge Challenger
#> 5:           Dodge Challenger,Merc 450SE,Valiant,Toyota Corona
#> 6:             Merc 450SE,Cadillac Fleetwood,Chrysler Imperial
#>                                            Four
#> 1:                                           NA
#> 2:                                    Merc 240D
#> 3:    Merc 240D,Mazda RX4 Wag,Fiat 128,Merc 280
#> 4:      Honda Civic,Fiat 128,Merc 230,Merc 240D
#> 5:                               Toyota Corolla
#> 6: Fiat 128,Merc 240D,Toyota Corolla,Datsun 710