Learn R Programming

SDDE (version 1.0.0)

sample_network: compares two networks using a path analysis of total pathways

Description

This function allows the user to compare two related networks (undirected graphs) by computing the number of paths of each category for a sample of nodes from the original graph.

Usage

sample_network(g1,g2,
					   size, 
					   taxnames,
					   maxdistance=0, 
					   maxtime=3600,
					   maxnode=0, 
					   verbose=FALSE, 
					   file='log.txt', 
					   maxcores=1, 
					   node1, 
					   node2,
					   sample_paths=c(),
					   old_path=c()
					)

Arguments

g1
the original network X
g2
the augmented network Y with additional nodes (all the original nodes from X must be present in the augmented network Y)
taxnames
the taxon name of the nodes added to the original graph (default: we select all nodes that are not in g1)
size
the number of pathways to sample or the percent of node to sample if smaller than 1.0 (default=10)
maxnode
the maximum number of augmented nodes in network Y to take into account (default=0, no maximum number of augmented nodes to take into account. The augmented nodes are sorted by distance to the investigated node pairs by the algorithm.)
maxtime
the maximum search time per pathway (default=3600 seconds)
maxdistance
the maximum search distance to the added nodes in network Y (default=0, no maximum distance for augmented nodes to take into account)
verbose
flag to save into a file additionnal informations regarding the obtained paths (default=FALSE, the file name should be indicated)
file
filename to save the additionnal informations
node1
if node1 is set,we look only for paths starting from node1
node2
if node2 is set, we will only look at the paths starting at node1 and ending at node2
maxcores
maximum number of cores to use (default=1, use 0 to use half of the total cores available)
sample_paths
vector containing a list of node numbers to sample. Note: this override the size argument
old_path
vector containing a list of node numbers already sampled

Value

  • This function returns the number of paths of each category: Shortcuts, Detours, Dead ends, Equal paths or disconnected nodes. If not all augmented nodes are visited because of the maxnode, maxtime or maxdistance limits, a path can also be classified as 'Detour or Dead End'.

encoding

ISO-8859-2

Examples

Run this code
## Sample 10 of the 55 pathways in Sample_1
	data(Sample_1)   
	sample_network(g1,g2, size=10)
	## Repeated sampling (5) of 10 pathways 
	old_path <- c()
	for (i in 1:5) {
       sample_paths <- sample_path(10, length(V(g1)), old_path=old_path);
       sample_network(g1,g2, sample_paths=sample_paths);
       old_path <- c(old_path,sample_paths); 
	 }

Run the code above in your browser using DataLab