graph_from_file: Read file to a PAFit_net object

View source: R/graph_from_file.R

graph_from_fileR Documentation

Read file to a PAFit_net object

Description

This function reads an input file to a PAFit_net object. Accepted formats are the edgelist format or the gml format.

Usage

 graph_from_file(file_name, format = "edgelist", type = "directed")

Arguments

file_name

A string indicates the file name.

format

String. Possible values are "edgelist" and "gml".

If format is "edgelist", we assume the following edgelist matrix format. Each row is assumed to be of the form (from_node_id to_node_id time_stamp). from_node_id is the id of the source node. to_node_id is the id of the destination node. time_stamp is the arrival time of the edge. from_node_id and to_node_id are assumed to be integers that are at least 0. They need not to be contiguous.

To register a new node i at time t without any edge, add a row with format (i -1 t). This works for both undirected and directed networks.

time_stamp can be either numeric or string. The value of a time-stamp can be arbitrary, but we assume that a smaller time_stamp (regarded so by the sort function in R) represents an earlier arrival time. Examples of time-stamps that satisfy this assumption are the integer 0:T, the string format ‘yyyy-mm-dd’, and the POSIX time.

If format is "gml", there must be a binary field directed indicating the type of the network (0: undirected, 1: directed). The required fields for an edge are: source, target, and time. source and target are the ID of the source node and the target node, respectively. time is the time-stamp of the edge. The required fields for a node are: id, isolated (binary) and time. The binary field isolated indicates whether this node is an isolated node when it enters the system or not. If isolated is 1, then time must contain the node's appearance time. If isolated is 0, then we can automatically infer the node's appearance time from its edges, so the field time in this case can be NULL. The assumptions on node IDs and the format of time-stamps are the same as in the case when format = "edgelist". See graph_to_file to see detail on the format of the gml file this package outputs.

type

String. Indicates whether the network is "directed" or "undirected". This option is ignored if format is "gml", since the information is assumed to be contained in the gml file.

Value

An object of class PAFit_net containing the network.

Author(s)

Thong Pham thongphamthe@gmail.com

Examples

  library("PAFit")
  # a network from Bianconi-Barabasi model
  net        <- generate_BB(N = 50 , m = 10 , s = 10)
  
  #graph_to_file(net, file_name = "test.gml", format = "gml")
  #reread    <- graph_from_file(file_name = "test.gml", format = "gml")

PAFit documentation built on June 22, 2024, 11:06 a.m.