plateform
stringclasses
1 value
repo_name
stringlengths
13
113
name
stringlengths
3
74
ext
stringclasses
1 value
path
stringlengths
12
229
size
int64
23
843k
source_encoding
stringclasses
9 values
md5
stringlengths
32
32
text
stringlengths
23
843k
github
prashanthvarma/Complex-Networks-Analysis-master
edgeL2adj.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/edgeL2adj.m
453
utf_8
2b1501cce9776d243bf7f88cd7a56bed
% Converts edge list to adjacency matrix % INPUTS: edgelist: mx3 % OUTPUTS: adjacency matrix nxn % Note: information about nodes is lost: indices only (i1,...in) remain % GB, Last updated: October 6, 2009 function adj=edgeL2adj(el) nodes=sort(unique([el(:,1) el(:,2)])); % get all nodes, sorted adj=zeros(numel(nodes))...
github
prashanthvarma/Complex-Networks-Analysis-master
vertex_eccentricity.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/vertex_eccentricity.m
288
utf_8
b2fc6d45bf236555f3af935eab315f90
% Vertex eccentricity - the maximum distance to any other vertex % Input: adjacency matrix % Output: vector of eccentricities % Other routines used: simple_dijkstra.m function ec=vertex_eccentricity(adj) n=size(adj,1); ec=zeros(1,n); for s=1:n; ec(s)=max( simple_dijkstra(adj,s) ); end
github
prashanthvarma/Complex-Networks-Analysis-master
nested_hierarchies_model.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/nested_hierarchies_model.m
2,356
utf_8
8de57170e7960601c8407225bc2d3f00
% Based on: Sales-Pardo et al, "Extracting the hierarchical organization of complex systems", PNAS, Sep 25, 2007; vol.104; no.39 % Supplementary material: http://www.pnas.org/content/suppl/2008/02/27/0703740104.DC1/07-03740SItext.pdf % INPUTs: N: number of nodes; L: number of hierarchy levels; [G1,G2,..,GL]: number of...
github
prashanthvarma/Complex-Networks-Analysis-master
isregular.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/isregular.m
351
utf_8
da563083fce0314c8aae55df2d467399
% Checks whether a graph is regular, i.e. every node has the same degree. % Note: Defined for unweighted graphs only. % INPUTS: adjacency matrix nxn % OUTPUTS: Boolean, yes/no % GB, Last updated: October 1, 2009 function S=isregular(adj) S=false; degs=sum(adj>0); % remove weights and sum columns if degs == degs(1)*...
github
prashanthvarma/Complex-Networks-Analysis-master
numnodes.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/numnodes.m
225
utf_8
f8b37d444a8e65749e9477d89b8f0ffe
% Returns the number of nodes, given an adjacency list % also works for an adjacency matrix % INPUTs: adjacency list: {i:j_1,j_2 ..} % OUTPUTs: number of nodes % GB, February 19, 2006 function n = numnodes(L) n = length(L);
github
prashanthvarma/Complex-Networks-Analysis-master
weighted_clust_coeff.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/weighted_clust_coeff.m
1,195
utf_8
21ae917626ef00a6d0dffa5696439371
% Weighted clustering coefficient % Source: Barrat, The architecture of complex weighted networks % INPUTS: weighted adjacency matrix % OUTPUTs: vector of node weighted clustering coefficients % Other routines used: degrees.m, kneighbors.m function wC=weighted_clust_coeff(adj) [deg,~,~]=degrees(adj); n=size(adj,1); ...
github
prashanthvarma/Complex-Networks-Analysis-master
pajek2adj.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/pajek2adj.m
337
utf_8
8ab7f3a8796a5b0925550050453baa82
% This program extracts an adjacency matrix from a pajek text (.net) file % INPUT .net text filename, n - number of nodes in the graph % OUTPUT: adjacency matrix, nxn, n - # nodes % Other routines used: pajek2edgeL.m, edgeL2adj.m % GB, October 7, 2009 function adj = pajek2adj(filename,n) el=pajek2edgeL(filename,n); a...
github
prashanthvarma/Complex-Networks-Analysis-master
adj2str.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/adj2str.m
595
utf_8
7af12888ae0ae39e140ffde4655c8f1e
% Converts an adjacency matrix to a one-line string representation % INPUTS: adjacency matrix, nxn % OUTPUTS: string % The nomenclature used to construct the string is arbitrary. Here we use % .i1.j1.k1,.i2.j2.k2,.... % Other routines used: kneighbors.m % GB, Last updated: October 6, 2009 function str=adj2str(adj) % ...
github
prashanthvarma/Complex-Networks-Analysis-master
graph_radius.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/graph_radius.m
223
utf_8
f5629cdf8d404dc212e5efc714bf7327
% The minimum vertex eccentricity is the graph radius % Inputs: adjacency matrix (nxn) % Outputs: graph radius % Other routines used: vertex_eccentricity.m function Rg=graph_radius(adj) Rg=min( vertex_eccentricity(adj) );
github
prashanthvarma/Complex-Networks-Analysis-master
average_degree.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/average_degree.m
291
utf_8
9c6a5314b85c245f9e756b03f464ae46
% Computes the average degree of a node in a graph, defined as 2*num_edges % divided by the num_nodes (every edge is counted in degrees twice). % Other routines used: numnodes.m, numedges.m % GB, Last Update: October 1, 2009 function k=average_degree(adj) k=2*numedges(adj)/numnodes(adj);
github
prashanthvarma/Complex-Networks-Analysis-master
issymmetric.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/issymmetric.m
260
utf_8
63bcd46eded9d2a755bd5cc8cd2252ce
% Checks whether a matrix is symmetric (has to be square) % Check whether mat=mat^T % INPUTS: adjacency matrix % OUTPUTS: boolean variable, {0,1} % GB, October 1, 2009 function S = issymmetric(mat) S = false; % default if mat == transpose(mat); S = true; end
github
prashanthvarma/Complex-Networks-Analysis-master
random_graph.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/random_graph.m
3,604
utf_8
7738900e50e4d9b0ff3b36e20a8d5dd2
% Random graph construction routine with various models % INPUTS: N - number of nodes % p - probability, 0<=p<=1, for all other inputs, p is not considered % E - fixed number of edges % distribution - probability distribution: use the "connecting-stubs model" generation model % degr...
github
prashanthvarma/Complex-Networks-Analysis-master
rich_club_metric.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/rich_club_metric.m
592
utf_8
b3d6ab40bb3db925ed4a83d6fc44c5ac
% Compute the rich club metric for a graph % INPUTs: adjacency matrix, nxn, k - threshold number of links % OUTPUTs: rich club metric % Source: Colizza, Flammini, Serrano, Vespignani, "Detecting rich-club ordering in complex networks", Nature Physics, vol 2, Feb 2006 % Other routines used: degrees.m, subgraph.m, numedg...
github
prashanthvarma/Complex-Networks-Analysis-master
canonical_nets.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/canonical_nets.m
7,870
utf_8
fb940a6a350a1415e208dbe26cd3e524
% Build edge lists for simple canonical graphs, ex: trees and lattices % INPUTS: number of nodes, net type, branch factor (for trees only) % Types can be 'line','circle','star','btree','tree','htree','trilattice','sqlattice','hexlattice', 'clique' % OUTPUTS: edgelist (mx3); additional outputs possible, see specific gr...
github
prashanthvarma/Complex-Networks-Analysis-master
link_density.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/link_density.m
365
utf_8
c9c4172fa311ac246e2c586512937f34
% Computes the link density of a graph, defined as num_edges divided by % num_nodes(num_nodes-1)/2 where the latter is the max possible num edges. % The graph needs to be non-trivial (more than 1 node). % Other routines used: numnodes.m, numedges.m % GB, Last Update: October 1, 2009 function d=link_density(adj) n = ...
github
prashanthvarma/Complex-Networks-Analysis-master
node_betweenness_faster.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/node_betweenness_faster.m
1,027
utf_8
047db628add2afc52c81089ebe73b72d
% Betweenness centrality measure: number of shortest paths running though a vertex % Compute for all vertices, using Dijkstra's algorithm, using 'number of shortest paths through a node' definition % Note: Valid for a general (connected) graph. % INPUTS: adjacency (distances) matrix (nxn) % OUTPUTS: betweeness vector ...
github
prashanthvarma/Complex-Networks-Analysis-master
s_metric.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/s_metric.m
892
utf_8
30ec94b507e61843e17234816e9c4c15
% The sum of products of degrees across all edges % Source: "Towards a Theory of Scale-Free Graphs: Definition, Properties, and Implications", by Li, Alderson, Doyle, Willinger % Note: The total degree is used regardless of whether the graph is directed or not. % INPUTs: adjacency matrix % OUTPUTs: s-metric % Other rou...
github
prashanthvarma/Complex-Networks-Analysis-master
graph_complement.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/graph_complement.m
249
utf_8
a384a97b3c90415e4054885e21986650
% Returns the complement of a graph % INPUTs: adj - original graph adjacency matrix % OUTPUTs: complement graph adjacency matrix % Note: Assumes no multiedges % GB, February 2, 2006 function adj_c = graph_complement(adj) adj_c=ones(size(adj))-adj;
github
prashanthvarma/Complex-Networks-Analysis-master
fiedler_vector.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/fiedler_vector.m
253
utf_8
fda4aa10cf56f040a9e649bf9e4532fd
% The vector corresponding to the second smallest eigenvalue of the Laplacian matrix % INPUTs: adjacency matrix (nxn) % OUTPUTs: fiedler vector (nx1) function fv=fiedler_vector(adj) [V,D]=eig(laplacian_matrix(adj)); [ds,Y]=sort(diag(D)); fv=V(:,Y(2));
github
prashanthvarma/Complex-Networks-Analysis-master
dijkstra.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/dijkstra.m
1,449
utf_8
ffcb3bb02ca50fa647781eeb3d444e19
% INPUTS: adj - adjacency matrix, s - source node, target - target node % OUTPUTS: distance, d and path, P (from s to target) % Note: if target==[], then dist and P include all distances and paths from s % Other routines used: adj2adjL.m, purge.m % GB, Last Updated: Dec 22, 2009 function [dist,P]=dijkstra(adj,s,target...
github
prashanthvarma/Complex-Networks-Analysis-master
eigencentrality.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/eigencentrality.m
332
utf_8
09b026358150b0bed5936cf3895792cd
% The ith component of the eigenvector corresponding to the greatest % eigenvalue gives the centrality score of the ith node in the network. % INPUTs: adjacency matrix % OUTPUTs: eigen(-centrality) vector % GB, Last Updated: October 14, 2009 function x=eigencentrality(adj) [V,D]=eig(adj); [max_eig,ind]=max(diag(D));...
github
prashanthvarma/Complex-Networks-Analysis-master
tarjan.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/tarjan.m
1,733
utf_8
5aa83caadb4ce4f54f81101a104b715a
% Find the giant stronly connected component in a directed graph % Source: Tarjan, R. E. (1972), "Depth-first search and linear graph algorithms", SIAM Journal on Computing 1 (2): 146-160 % Input: graph, set of nodes and edges, in adjacency list format, ex: L{1}=[2], L{2]=[1] is the 1-2 edge % Outputs: set of strongly ...
github
prashanthvarma/Complex-Networks-Analysis-master
PriceModel.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/PriceModel.m
1,029
utf_8
0c38c192336268b44a6e887e656266f9
% Routine implementing the Price model for network growth % Notes: % p_k - fraction of vertices with degree k % probability a new vertex attaches to any of the degree-k vertices is % (k+1)p_k/(m+1), where m - mean number of new citations per vertex % Source: "The Structure and Function of Complex Networks", M.E....
github
prashanthvarma/Complex-Networks-Analysis-master
forestFireModel.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/forestFireModel.m
1,853
utf_8
4394a4fa96bdeff6b9ade7183dc95cca
% Implementation of the forest fire model by Leskovec et al % Source: Graphs over Time: Densification Laws, Shrinking Diameters and Possible Explanations % Inputs: forward burning probability p in [0,1], % backward burning ratio r, in [1,inf), % T - number of nodes % Outputs: adjacency list of the cons...
github
prashanthvarma/Complex-Networks-Analysis-master
random_modular_graph.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/random_modular_graph.m
1,249
utf_8
e5fb109d3f9460992e128747731e1441
% Build a random modular graph, given number of modules, and link density % INPUTs: number of nodes, number of modules, total link density, % and proportion of links within modules compared to links across % OUTPUTs: adjacency matrix, modules to which the nodes are assigned % GB, Last updated: October 19, 2009 ...
github
prashanthvarma/Complex-Networks-Analysis-master
istree.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/istree.m
335
utf_8
1fc3d238ecd94ba0772235494fa35085
% Check whether a graph is a tree % Source: "Intro to Graph Theory" by Bela Bollobas % INPUTS: adjacency matrix % OUTPUTS: Boolean variable % Other routines used: isconnected.m, numedges.m, numnodes.m % GB, Last Updated: June 19, 2007 function S=istree(adj) S=false; if isconnected(adj) & numedges(adj)==numnodes(adj)...
github
prashanthvarma/Complex-Networks-Analysis-master
adj2simple.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/adj2simple.m
407
utf_8
64d978907cd90f0c39f378d82bdcd75d
% Convert an adjacency matrix of a general graph to the adjacency matrix of % a simple graph (no loops, no double edges) - great for quick data clean up % INPUTS: adjacency matrix % OUTPUTs: adjacency matrix of the corresponding simple graph % GB, Last updated: October 4, 2009 function adj=adj2simple(adj) adj=adj>0; ...
github
prashanthvarma/Complex-Networks-Analysis-master
adj2pajek.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/adj2pajek.m
2,167
utf_8
fbd109998af47215482b493fd4ae48b5
% Converts an adjacency matrix representation to a Pajek .net read format % INPUT: an adjacency matrix, [nxn], a filename, [string], node coordinates (optional) % OUTPUT: text format of Pajek readable .net (or .txt) file in the same directory % Note 1: If node coordinates are not provided, random numbers between 0 and ...
github
prashanthvarma/Complex-Networks-Analysis-master
edgeL2pajek.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/edgeL2pajek.m
1,339
utf_8
e6160be8b26e7528d88528abe916aeac
% Converts an edgelist matrix representation to a Pajek .net readable format % INPUT: an edgelist matrix, [mx3], a filename, [string] % OUTPUT: text format of Pajek readable .net file % See also: adj2pajek.m % Other routines used: edgeL2adj.m, issymmetric.m % EXAMPLE % *Vertices 4 % 1 "14" ...
github
prashanthvarma/Complex-Networks-Analysis-master
num_loops.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/num_loops.m
546
utf_8
ee658d8413f05f4412b7e1b10a52597a
% Calculate the number of independent loops (use G=m-n+c) % where G = num loops, m - num edges, n - num nodes, c - num_connected_components % This is also known as the "cyclomatic number" or the number of edges that need to be removed so that the graph cannot have cycles. % INPUTS: adjacency matrix % OUTPUTs: number of...
github
prashanthvarma/Complex-Networks-Analysis-master
numedges.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/numedges.m
702
utf_8
5c2bb553a2573d9236da193cca248115
% Returns the total number of edges given the adjacency matrix % Valid for both directed and undirected, simple or general graph % INPUTs: adjacency matrix % OUTPUTs: m - total number of edges/links % Other routines used: selfloops.m, issymmetric.m % GB, Last Updated: October 1, 2009 function m = numedges(adj) sl=sel...
github
prashanthvarma/Complex-Networks-Analysis-master
loops3.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/loops3.m
252
utf_8
35f24b3703dd3af444eb87be8fea84b4
% Calculates number of loops of length 3 % INPUTs: adj - adjacency matrix % OUTPUTs: L3 - number of triangles (loops of length 3) % Valid for an undirected network % GB, April 6, 2006 function L3 = loops3(adj) L3 = trace(adj^3)/6; % trace(adj^3)/3!
github
prashanthvarma/Complex-Networks-Analysis-master
graph_dual.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/graph_dual.m
1,239
utf_8
3c6fe1d0999b16a091e2e5815f6dccda
% Finds the dual of a graph; a dual is the inverted nodes-edges graph % This is also called the line graph, adjoint graph or the edges adjacency % INPUTs: adjacency (neighbor) list representation of the graph (see adj2adjL.m) % OUTPUTs: adj (neighbor) list of the corresponding dual graph and cell array of edges % Note:...
github
prashanthvarma/Complex-Networks-Analysis-master
isgraphic.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/isgraphic.m
753
utf_8
85d75fa8e9a5a26eb1854a366c09c9f7
% Check whether a sequence of number is graphical, i.e. a graph with this degree sequence exists % INPUTs: a sequence (vector) of numbers % OUTPUTs: boolean, true or false % Note: not generalized to directed graph degree sequences % Source: Erdős, P. and Gallai, T. "Graphs with Prescribed Degrees of Vertices" [Hungaria...
github
prashanthvarma/Complex-Networks-Analysis-master
pajek2xyz.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/pajek2xyz.m
761
utf_8
44651c6186cbff3c43cef36d33e51136
% Read x,y,z node coordinates from a pajek .net file - useful for plotting in Matlab % INPUTS: filename, string format % OUTPUTS: x,y,z coordinate vectors % GB, Last updated: October 7, 2009 function [x,y,z]=pajek2xyz(filename) f=fopen(filename,'r'); C = textscan(f, '%s'); c=C{1}; ind_edges=find(ismember(c, '*Edges'...
github
prashanthvarma/Complex-Networks-Analysis-master
edgeL2simple.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/edgeL2simple.m
531
utf_8
6ad7e81c0762dfcff4f8d37b0c7a8f40
% Convert an edge list of a general graph to the edge list of a simple % graph (no loops, no double edges) - great for quick data clean up % INPUTS: edgelist (mx3), m - number of edges % OUTPUTs: edge list of the corresponding simple graph % Note: Assumes all node pairs [n1,n2,x] occur once; if else see add_edge_weigh...
github
prashanthvarma/Complex-Networks-Analysis-master
sort_nodes_by_sum_neighbor_degrees.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/sort_nodes_by_sum_neighbor_degrees.m
996
utf_8
de0a508e63c114f561adac24e52ec319
% Sort nodes by degree, and where there's equality, by sum of neighbor degrees and then neighbors' neighbors degree and so on % Ideas from s-max algorithm by Li et al 2005 "Towards a theory of scale-free graphs" % and Guo, Chen, Zhou, "Fingerprint for Network Topologies" % INPUTS: adjacency matrix, 0s and 1s % OUTPUTS:...
github
prashanthvarma/Complex-Networks-Analysis-master
inc2adj.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/inc2adj.m
960
utf_8
b67cad22bb8006a5b50503db8497f470
% Converts an incidence matrix representation to an adjacency % matrix representation for an arbitrary graph % INPUTs: incidence matrix, nxm % OUTPUTs: adjacency matrix, nxn % GB, October 5, 2009 function adj = inc2adj(inc) m = size(inc,2); % number of edges adj = zeros(size(inc,1)); % initialize adjacency matrix i...
github
prashanthvarma/Complex-Networks-Analysis-master
giant_component.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/giant_component.m
410
utf_8
9535f8036ed3b419209e8e4accfa717f
% extract giant component from a network % INPUTS: adjacency matrix % OUTPUTS: giant comp matrix and node indeces % Other routines used: find_conn_comp.m, subgraph.m % GB, Last Updated: October 2, 2009 function [GC,gc_nodes]=giant_component(adj) comps=find_conn_comp(adj); L=[]; for k=1:length(comps); L=[L, length(c...
github
prashanthvarma/Complex-Networks-Analysis-master
isdirected.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/isdirected.m
257
utf_8
9596db5950cb34227826089f2d4e655c
% Using the matrix transpose function % INPUTS: adjacency matrix % OUTPUTS: boolean variable % GB, Last updated: October 1, 2009 function S=isdirected(adj) S = true; if adj==transpose(adj); S = false; end % one-liner alternative: S=not(issymmetric(adj));
github
prashanthvarma/Complex-Networks-Analysis-master
purge.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/purge.m
333
utf_8
5dc4f1d9a4a932043bdbf41957a35b67
% Removes a subset from a set, but preserves order of elements % Similar to setdiff - which sorts the elements % INPUTs: original set A, subset to remove B % OUTPUTs: set Anew = A-B % GB, Last updated: October 12, 2009 function Anew = purge(A,B) Anew = []; for a=1:numel(A); if isempty(find(B==A(a))); Anew=[Anew, A...
github
prashanthvarma/Complex-Networks-Analysis-master
str2adj.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/str2adj.m
1,037
utf_8
f9941058e03f1fef255a9eeb5e7f7725
% Converts a string graph representation to an adjacency matrix % Note: The string nomenclature is arbitrary % INPUTs: string variable of the format: .i1.j1.k1,.i2.j2.k2,.... % OUTPUTs: adjacency matrix, nxn % Note 1: Valid for a general graph % Note 2: This is the reverse routine for adj2str.m % GB, October 6, 2009 f...
github
prashanthvarma/Complex-Networks-Analysis-master
simple_dijkstra.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/simple_dijkstra.m
766
utf_8
44d0861a75a60d83726084ec89876b94
% Implements a simple version of the Dijkstra shortest path algorithm % Returns the distance from a single vertex to all others, doesn't save the path % INPUTS: adjacency matrix (adj), start node (s) % OUTPUTS: shortest path length from start node to all other nodes % Note: works with a weighted/directed matrix % GB, L...
github
prashanthvarma/Complex-Networks-Analysis-master
adj2inc.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/adj2inc.m
1,272
utf_8
21544e6dfbfc390e4e20340f90e0781c
% Convert adjacency matrix to an incidence matrix % Valid for directed/undirected, simple/not simple graph % INPUTs: adjacency matrix, NxN, N - number of nodes % OUTPUTs: incidence matrix: N x number of edges % Other routines used: isdirected.m % GB, Last Updated: July 10, 2011 function inc = adj2inc(adj) n=length(ad...
github
prashanthvarma/Complex-Networks-Analysis-master
num_conn_comp.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/num_conn_comp.m
431
utf_8
1084d55de1f452459b7372b438df4554
% Calculate the number of connected components using the Laplacian % eigenvalues - counting the number of zeros % INPUTS: adjacency matrix % OUTPUTs: positive integer - number of connected components % Other routines used: graph_spectrum.m % GB, Last updated: October 22, 2009 function nc=num_conn_comp(adj) s=graph_sp...
github
prashanthvarma/Complex-Networks-Analysis-master
DoddsWattsSabel.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/DoddsWattsSabel.m
1,956
utf_8
de99f63df9741eb23edf8bef62a6fdea
% Add random cross-links on top of a perfect hierarchy % Non-backbone edges are added with probability P(i,j)=e^(-Dij/lambda)*e^(-xij/ksi), % where Dij is the level of the lowest common ancestor and xij is the "organizational" distance % Source: Dodds, Watts, Sabel, "Information exchange and the robustness of organ...
github
prashanthvarma/Complex-Networks-Analysis-master
multiedges.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/multiedges.m
211
utf_8
c636b62463bc702f4115c0099a6a82d5
% counts the number of multiple edges in the graph % INPUT: adjacency matrix % OUTPUT: interger, number of multiple edges % Last Updated: GB, October 1, 2009 function mE=multiedges(adj) mE=length(find(adj>1));
github
prashanthvarma/Complex-Networks-Analysis-master
graph_spectrum.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/graph_spectrum.m
228
utf_8
eddf752487b9e372f365d999cf69b4f3
% The eigenvalues of the Laplacian of the graph % INPUTs: adjacency matrix % OUTPUTs: laplacian eigenvalues, sorted function s=graph_spectrum(adj) [v,D]=eig(laplacian_matrix(adj)); s=-sort(-diag(D)); % sort in decreasing order
github
prashanthvarma/Complex-Networks-Analysis-master
min_span_tree.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/min_span_tree.m
1,157
utf_8
bcabcd05b8a4da735ddc67e60ff3ebb5
% Prim's minimal spanning tree algorithm % Prim's alg idea: % start at any node, find closest neighbor and mark edges % for all remaining nodes, find closest to previous cluster, mark edge % continue until no nodes remain % INPUTS: graph defined by adjacency matrix % OUTPUTS: matrix specifying minimum spanning tree ...
github
prashanthvarma/Complex-Networks-Analysis-master
num_conn_triples.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/num_conn_triples.m
544
utf_8
110de16713b263ee2d37f676fea0c610
% Counts the number of connected triples in a graph % INPUTs: adjacency matrix % OUTPUTs: integer - num conn triples % Other routines used: kneighbors.m, loops3.m % Note: works for undirected graphs only % GB, Last updated: October 9, 2009 function c=num_conn_triples(adj) c=0; % initialize for i=1:length(adj) n...
github
prashanthvarma/Complex-Networks-Analysis-master
adjL2adj.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/adjL2adj.m
343
utf_8
db90beccb8ed769b1516201fed70f899
% Convert an adjacency list to an adjacency matrix % INPUTS: adjacency list: {n} % OUTPUTS: adjacency matrix nxn % Note: Assume that if node i has no neighbours, L{i}=[]; % GB, Last updated: October 6, 2009 function adj=adjL2adj(adjL) adj = zeros(length(adjL)); for i=1:length(adjL) for j=1:length(adjL{i}); adj(i...
github
prashanthvarma/Complex-Networks-Analysis-master
edge_betweenness.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/edge_betweenness.m
3,838
utf_8
82d506b662223f087f3105c6194d2f3b
% Edge betweenness routine, based on shortest paths % INPUTs: edgelist, mx3, m - number of edges % OUTPUTs: w - betweenness per edge % Note: Valid for undirected graphs only % Source: Newman, Girvan, "Finding and evaluating community structure in networks" % Other routines used: adj2edgeL.m, numnodes.m, numedges.m, kne...
github
prashanthvarma/Complex-Networks-Analysis-master
el2geom.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/el2geom.m
1,535
utf_8
d1c4fe1b13a8ab684f79a13c860f6692
% Plot geometry based on extended edgelist % INPUTS: extended edgelist el[i,:]=[n1 n2 m x1 y1 x2 y2] % OUTPUTS: geometry plot, higher-weight links are thicker and lighter % Note 1: m - edge weight; (x1,y1) are the Euclidean coordinates of n1, (x2,y2) - n2 resp. % Note 2: Easy to change colors and corresponding edge we...
github
prashanthvarma/Complex-Networks-Analysis-master
ave_path_length.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/ave_path_length.m
485
utf_8
b239a8493a131f840feeff93355722bb
% Compute average path length for a network - the average shortest path % INPUTS: adjL - matrix of weights/distances between nodes % OUTPUTS: average path length: the average of the shortest paths between every two edges % Note: works for directed/undirected networks % GB, December 8, 2005 function l = ave_path_length...
github
prashanthvarma/Complex-Networks-Analysis-master
rewire_disassort.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/rewire_disassort.m
1,255
utf_8
269669174b4cd7fa67f9dc956c0ea991
% Degree-preserving random rewiring % Every rewiring decreases the assortativity (pearson coefficient) % Note 1: There are rare cases of neutral rewiring (coeff stays the same within numerical error) % Note 2: Assume unweighted undirected graph % INPUTS: edgelist, el and number of rewirings, k % OUTPUTS: rewired edgeli...
github
prashanthvarma/Complex-Networks-Analysis-master
radial_plot.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/radial_plot.m
3,422
utf_8
871c4d0f094d2eba426fb6e795354d1e
% Plots nodes radially out from a given center. Equidistant nodes % have the same radius, but different angles. Works best as a quick % visualization for trees, or very sparse graphs. % Note 1: No spring-energy method implemented. % Note 2: If a center node is not specified, the nodes are ordered by % sum of neighbor ...
github
prashanthvarma/Complex-Networks-Analysis-master
isweighted.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/isweighted.m
307
utf_8
045573a6f9b4cb8c72cf9e81a45b9be7
% Check whether a graph is weighted, i.e not all edges are 0,1. % INPUTS: edge list, m x 3, m: number of edges, [node 1, node 2, edge weight] % OUTPUTS: Boolean variable, yes/no % GB, Last updated: October 1, 2009 function S=isweighted(el) S=true; if numel( find(el(:,3)==1) ) == size(el,1); S=false; end
github
prashanthvarma/Complex-Networks-Analysis-master
graph_similarity.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/graph_similarity.m
737
utf_8
82376ec972ae128e0bfd27d7b48028a8
% Computes the similarity matrix between two graphs % Ref: "A measure of similarity between graph vertices: % applications to synomym extraction and web searching" % Blondel, SIAM Review, Vol. 46, No. 4, pp. 647-666 % Inputs: A, B - two graphs adjacency matrices, mxm and nxn % Outputs: S - similarity matrix, mxn % Last...
github
prashanthvarma/Complex-Networks-Analysis-master
adjL2edgeL.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/adjL2edgeL.m
272
utf_8
c24ec53465dbf161886a1ec25a4a3d8d
% Converts adjacency list to an edge list % INPUTS: adjacency list % OUTPUTS: edge list % GB, Last Updated: October 6, 2009 function el = adjL2edgeL(adjL) el = []; % initialize edgelist for i=1:length(adjL) for j=1:length(adjL{i}); el=[el; i, adjL{i}(j), 1]; end end
github
prashanthvarma/Complex-Networks-Analysis-master
diameter.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/diameter.m
335
utf_8
d9992d55ce6f495d679b7df0cb7a76c7
% The longest shortest path between any two nodes nodes in the network % INPUTS: adjacency matrix, adj % OUTPUTS: network diameter, diam % Other routines used: simple_dijkstra.m % GB, Last updated: June 8, 2010 function diam = diameter(adj) diam=0; for i=1:size(adj,1) d=simple_dijkstra(adj,i); diam = max([max...
github
prashanthvarma/Complex-Networks-Analysis-master
adj2adjL.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/adj2adjL.m
411
utf_8
9dcd7d329d1123d1909bdb66ba283327
% Converts an adjacency graph representation to an adjacency list % Valid for a general (directed, not simple) network model, but edge % weights get lost in the conversion. % INPUT: an adjacency matrix, NxN, N - # of nodes % OUTPUT: cell structure for adjacency list: x{i_1}=[j_1,j_2 ...] % GB, October 1, 2009 function...
github
prashanthvarma/Complex-Networks-Analysis-master
num_star_motifs.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/num_star_motifs.m
503
utf_8
0bfa482372798254d4aded546946d37e
% Calculates the number of star motifs of given (subgraph) size % Easily extendible to return the actual stars as k-tuples of nodes % INPUTs: adjacency matrix of original graph, k - size of the star motif % OUTPUTs: number of stars with k nodes (k-1 spokes) % Other routines used: degrees.m % Note: star of size 1 is the...
github
prashanthvarma/Complex-Networks-Analysis-master
isconnected.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/isconnected.m
1,802
utf_8
d49e273550e7e55a897c208f835673ad
% Determine if a graph is connected % INPUTS: adjacency matrix % OUTPUTS: Boolean variable {0,1} % Note: this only works for undirected graphs % Idea by Ed Scheinerman, circa 2006, source: http://www.ams.jhu.edu/~ers/matgraph/ % routine: matgraph/@graph/isconnected.m function S = is...
github
prashanthvarma/Complex-Networks-Analysis-master
modularity_metric.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/modularity_metric.m
1,568
utf_8
072dbf35dc30ed72bebe7c8ad86361bc
% Computing the modularity for a given module/commnunity break-down % Defined as: Q=sum_over_modules_i (eii-ai^2) (eq 5) in Newman and Girvan. % eij = fraction of edges that connect community i to community j, ai=sum_j (eij) % Source: Newman, M.E.J., Girvan, M., "Finding and evaluating community structure in networks" ...
github
prashanthvarma/Complex-Networks-Analysis-master
adj2edgeL.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/adj2edgeL.m
369
utf_8
726a2ad04d68d1c368b86a70730fc234
% Converts adjacency matrix (nxn) to edge list (mx3) % INPUTS: adjacency matrix: nxn % OUTPUTS: edge list: mx3 % GB, Last updated: October 2, 2009 function el=adj2edgeL(adj) n=length(adj); % number of nodes edges=find(adj>0); % indices of all edges el=[]; for e=1:length(edges) [i,j]=ind2sub([n,n],edges(e)); % node...
github
prashanthvarma/Complex-Networks-Analysis-master
degrees.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/degrees.m
522
utf_8
a84c21eaa099ed34ba358bab5707d4f5
% Compute the total degree, in-degree and out-degree of a graph based on % the adjacency matrix; should produce weighted degrees, if the input matrix is weighted % INPUTS: adjacency matrix % OUTPUTS: degree, indegree and outdegree sequences % GB, Last Updated: October 2, 2009 function [deg,indeg,outdeg]=degrees(adj) ...
github
prashanthvarma/Complex-Networks-Analysis-master
newmangastner.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/newmangastner.m
1,581
utf_8
2582fbfc9e5c0a7fc7ced5fdb4f27e93
% Implements the Newman-Gastner model for spatially distributed networks % Source: Newman, Gastner, "Shape and efficiency in spatial distribution networks" % Note 1: minimize: wij = dij + beta x (dj0) % Note 2: easy to change to input point coordinates, instead of generate randomly % Inputs: n - number of points/nodes,...
github
prashanthvarma/Complex-Networks-Analysis-master
build_smax_graph.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/build_smax_graph.m
5,068
utf_8
a6dff8eceb8f3bdc1ec177b5b884a807
% Construct the graph with the maximum possible s-metric, given the degree % sequence; the s-metric is the sum of products of degrees across all edges % Source: Li et al "Towards a Theory of Scale-Free Graphs" % INPUTs: degree sequence: 1xn vector of positive integers % OUTPUTs: edgelist of the s-max graph, mx3 % Other...
github
prashanthvarma/Complex-Networks-Analysis-master
newman_comm_fast.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/newman_comm_fast.m
3,479
utf_8
20b8dc9e74edc11601ce79be077391d0
% Newman fast community finding algorithm % Source: "Fast algorithm for detecting community structure in networks", Mark Newman % Input: adjacency matrix % Output: group (cluster) formation over time, modularity metric for each cluster breakdown % Other functions used: numedges.m % Originally: June 6, 2007, GB, last mo...
github
prashanthvarma/Complex-Networks-Analysis-master
find_conn_comp.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/find_conn_comp.m
1,439
utf_8
597d084c5e1da29ec68c8236a1ab772d
% Algorithm for finding connected components in a graph % Valid for undirected graphs only % INPUTS: adj - adjacency matrix % OUTPUTS: a list of the components comp{i}=[j1,j2,...jk} % Other routines used: find_conn_compI.m (embedded), degrees.m, kneighbors.m % GB, Last updated: October 2, 2009 function comp_mat = fi...
github
prashanthvarma/Complex-Networks-Analysis-master
edgeL2adjL.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/edgeL2adjL.m
293
utf_8
d97fdd10c0697323ff8ad37487af389a
% Converts an edgelist to an adjacency list % INPUTS: edgelist, (mx3) % OUTPUTS: adjacency list % GB, Last updated: October 13, 2006 function adjL = edgeL2adjL(el) nodes = unique([el(:,1)' el(:,2)']); adjL=cell(numel(nodes),1); for e=1:size(el,1); adjL{el(e,1)}=[adjL{el(e,1)},el(e,2)]; end
github
prashanthvarma/Complex-Networks-Analysis-master
sort_nodes_by_max_neighbor_degree.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/sort_nodes_by_max_neighbor_degree.m
719
utf_8
d39339b7fdc93d005e68a337347a8432
% Sort nodes by degree, and where there's equality, by maximum neighbor degree % Ideas from Guo, Chen, Zhou, "Fingerprint for Network Topologies" % INPUTS: adjacency matrix, 0s and 1s % OUTPUTS: sorted sequence from 1 to n, where n is the number of rows/cols of the adjacency % Other routines used: degrees.m, kneighbors...
github
prashanthvarma/Complex-Networks-Analysis-master
kneighbors.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/kneighbors.m
302
utf_8
f6202976c531ddfc15e6ef0c09c8487b
% Finds the number of k-neighbors (k links away) for every node % INPUTS: adjacency matrix, node index, k - number of links % OUTPUTS: vector of k-neighbors indices % GB, May 3, 2006 function kneigh = kneighbors(adj,ind,k) adjk = adj; for i=1:k-1; adjk = adjk*adj; end; kneigh = find(adjk(ind,:)>0);
github
prashanthvarma/Complex-Networks-Analysis-master
leaf_edges.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/leaf_edges.m
793
utf_8
84d28c1ef0b1e3c6405eb1a6ee1ae2d3
% Return the leaf edges of the graph: edges with one adjacent edge only % Leaf edges have only one associated leaf node, otherwise they are single floating disconnected edges. % Assumptions: % Note 1: For a directed graph, leaf edges are those that "flow into" the leaf node % Note 2: There could be other definitions o...
github
prashanthvarma/Complex-Networks-Analysis-master
symmetrize_edgeL.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/symmetrize_edgeL.m
458
utf_8
12ea5e1060cfe27d9bf1fefc90387211
% Making an edgelist (representation of a graph) symmetric % INPUTs: edge list, mx3 % OUTPUTs: symmetrized edge list, mx3 % GB, Last updated: October 8, 2009 function el=symmetrize_edgeL(el) el2=[el(:,1), el(:,2)]; for e=1:size(el,1) ind=ismember(el2,[el2(e,2),el2(e,1)],'rows'); if sum(ind)==0; el=[el; el(e,...
github
prashanthvarma/Complex-Networks-Analysis-master
exponential_growth_model.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/exponential_growth_model.m
400
utf_8
fa00cfdcbd1094d56edc596cd6d51c70
% Grow a network exponentially % Probability of node s having k links at time t: p(k,s,t)=1/t*p(k-1,s,t-1)+(1-1/t)*p(k,s,t-1) % INPUTS: number of time-steps, t % OUTPUTs: edgelist, mx3 % GB, Last Updated: May 7, 2007 function el=exponential_growth_model(t) el=[1 2 1; 2 1 1]; % initialize with two connected nodes % f...
github
prashanthvarma/Complex-Networks-Analysis-master
algebraic_connectivity.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/algebraic_connectivity.m
231
utf_8
ba65837e861918e4286675151c56ade4
% The algebraic connectivity of a graph: the second smallest eigenvalue of the Laplacian % INPUTs: adjacency matrix % OUTPUTs: algebraic connectivity function a=algebraic_connectivity(adj) s=graph_spectrum(adj); a=s(length(s)-1);
github
prashanthvarma/Complex-Networks-Analysis-master
clust_coeff.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/clust_coeff.m
1,124
utf_8
20e886d07c2c892456520f77f896ecfb
% Computes clustering coefficient, based on triangle motifs count and local clustering % C1 = num triangle loops / num connected triples % C2 = the average local clustering, where Ci = (num triangles connected to i) / (num triples centered on i) % Ref: M. E. J. Newman, "The structure and function of complex networks" %...
github
prashanthvarma/Complex-Networks-Analysis-master
random_directed_graph.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/random_directed_graph.m
517
utf_8
7034a164931ad3a7fa080bad05b24700
% Random directed graph construction % INPUTS: N - number of nodes % p - probability, 0<=p<=1 % Output: adjacency matrix % Note 1: if p is omitted, p=0.5 is default % Note 2: no self-loops, no double edges function adj = random_directed_graph(n,p) adj=zeros(n); % initialize adjacency matrix if nargin==1; p...
github
prashanthvarma/Complex-Networks-Analysis-master
getNodes.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/getNodes.m
827
utf_8
694eae7aaa73f6b7cd39bfb6dba871cb
% return the list of nodes for varying representation types % inputs: graph structure (matrix or cell or struct) and type of structure % (string) % 'type' can be: 'adj','edgelist','adjlist' (neighbor list),'inc' (incidence matrix) % Note 1: only the edge list allows/returns non-consecutive node indexing % Note 2: no bu...
github
prashanthvarma/Complex-Networks-Analysis-master
inc2edgeL.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/inc2edgeL.m
728
utf_8
7c48b8c1258857df4d649e6a2b228e89
% Converts an incidence matrix to an edgelist % inputs: inc - incidence matrix nxm % outputs: edgelist - mx3 % GB, Last Updated: June 9, 2006 function el = inc2edgeL(inc) m = size(inc,2); % number of edges el = zeros(m,3); % initialize edgelist [n1, n2, weight] for e=1:m ind_m1 = find(inc(:,e)==-1); ind_p1 =...
github
prashanthvarma/Complex-Networks-Analysis-master
newmangirvan.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/newmangirvan.m
2,125
utf_8
b1556f5556916ea96807d0dd28fddd5b
% Newman-Girvan community finding algorithm % source: Newman, M.E.J., Girvan, M., "Finding and evaluating community structure in networks" % Algorithm idea: % 1. Calculate betweenness scores for all edges in the network. % 2. Find the edge with the highest score and remove it from the network. % 3. Recalculate betweenn...
github
prashanthvarma/Complex-Networks-Analysis-master
issimple.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/issimple.m
352
utf_8
09055a7694198df590b61fe1f64a5735
% Checks whether a graph is simple (no self-loops, no multiple edges) % INPUTs: adj - adjacency matrix % OUTPUTs: S - a Boolean variable % Other routines used: selfloops.m, multiedges.m % GB, Last updated: October 1, 2009 function S = issimple(adj) S=true; % check for self-loops or double edges if selfloops(adj)>0 |...
github
prashanthvarma/Complex-Networks-Analysis-master
simple_spectral_partitioning.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/simple_spectral_partitioning.m
1,172
utf_8
14c411516a8e06f3365e7093f80921ef
% Uses the fiedler vector to assign nodes to groups % INPUTS: adj - adjancency matrix, k - desired number of nodes in groups [n1, n2, ..], [optional] % OUTPUTs: modules - [k] partitioned groups of nodes % Other functions used: fiedler_vector.m function modules = simple_spectral_partitioning(adj,k) % find the Fiedler ...
github
prashanthvarma/Complex-Networks-Analysis-master
selfloops.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/selfloops.m
197
utf_8
8e4f475bc083530b62ca862f89163fd6
% counts the number of self-loops in the graph % INPUT: adjacency matrix % OUTPUT: interger, number of self-loops % Last Updated: GB, October 1, 2009 function sl=selfloops(adj) sl=sum(diag(adj));
github
prashanthvarma/Complex-Networks-Analysis-master
draw_circ_graph.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/draw_circ_graph.m
796
utf_8
d4a699654578af95523d415a96313ec3
% Draw a circular graph with links and nodes in order of degree % Strategy: position vertices in a regular n-polygon % INPUTs: adj - adjacency matrix % OUTPUTs: a figure % Other routines used: degrees.m % GB, February 21, 2006 function [] = draw_circ_graph(adj) n = size(adj,1); % number of nodes [degs,~,~]=degrees(ad...
github
prashanthvarma/Complex-Networks-Analysis-master
graph.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/@graph/graph.m
25,604
utf_8
0777135d847ced8192cc16ab36d95c5c
function g = graph(varargin) % graph - graph object constructor % % g = graph create a graph using GUI % % g = graph(adj) adjecency matrix, give symmetric matrix for % undirected graph % g = graph(adj, nodeLabels) adjecency matrix with node id % g = graph(adj, nodeLabels, graphName) % % g = graph(elist...
github
prashanthvarma/Complex-Networks-Analysis-master
layout.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/@graph/layout.m
8,675
utf_8
d88a656e64ce33b973113ccde5b87495
function g = layout(g, method) % LAYOUT - layout the graph % % g = layout(g) layout the graph with default method (force directed). % g = layout(g, method) layout the graph with provide methods. available % methods are 'random', 'force directed', 'group', 'graphviz'. % % For 'GraphViz', MATLAB - GraphViz int...
github
prashanthvarma/Complex-Networks-Analysis-master
plot.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/@graph/plot.m
2,682
utf_8
37884fa955174ad7ece1e940f36a8105
function plot(g, varargin) % GRAPH/PLOT - plot a graph % % plot(g) % plot(g, ...) % Options: % ShowNodeLabel - 1 to show label % Fast - 1 to draw fastly using build-in function gplot, this % will ignore some options like ShowNodeLabel n = length(g.nodes); w = g.nodeSize; h =...
github
prashanthvarma/Complex-Networks-Analysis-master
allspath.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/@graph/allspath.m
2,235
utf_8
b4527ccba52e435c57bd41f20fbe7f2b
function B = allspath(g, th) % ALLSPATH - solve the All Pairs Shortest Path problem for undirected graph % % Rapidly returns the shortest node-to-node distance along the edges of a % graph, for all nodes in the graph. % % B = allspath(g) % % g = input graph % B = shortest path distance matrix between all nodes % ...
github
prashanthvarma/Complex-Networks-Analysis-master
export.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/@graph/export.m
6,712
utf_8
ad6e92ece57332627361e2fab79f6b0a
function export(g, fn) % export - save graph into various file format % % export(g, filename) export the graph to give file name for given % output file type. Supported file file type are SIF, GML and DOT. % % export(g, filename) export with default SIF format % Kyaw Tun, RIKEN 2006 % DOT is inspired by by Dr. Leo...
github
prashanthvarma/Complex-Networks-Analysis-master
astar_search.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/matlab_bgl/astar_search.m
3,582
utf_8
528ff641877279dc012bed23ea2d9d21
function [d pred f]=astar_search(A,s,h,varargin) % ASTAR_SEARCH Perform a heuristically guided (A*) search on the graph. % % [d pred rank]=astar_search(A,s,h,optionsu) returns the distance map, % search tree and f-value of each node in an astar_search. % The search begins at vertex s. The heuristic h guides the searc...
github
prashanthvarma/Complex-Networks-Analysis-master
grid_graph.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/matlab_bgl/grid_graph.m
2,474
utf_8
bd3a3e48fad748a8b3b57dab5570c97c
function [A coords] = grid_graph(varargin) % GRID_GRAPH Generate a grid graph or hypergrid graph % % [A xy] = grid_graph(m,n) generates a grid graph with m vertices along the % x axis and n vertices along the y axis. The xy output gives the 2d % coordinates of each vertex. % [A xyz] = grid_graph(m,n,k) generates a ...
github
prashanthvarma/Complex-Networks-Analysis-master
path_histogram.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/matlab_bgl/custom/path_histogram.m
2,057
utf_8
8ba677da99d2a4a4e26d41487c0ea5db
function [l c] = path_histogram(G,varargin) % PATH_HISTOGRAM Compute a histogram of all shortest paths in graph G % % [l c] = path_histogram(G) computes all shortest paths in A one at a time % and forms the histogram of the shortest distances between all vertices. % % [l c] = path_histogram(G,struct('sample',N)) uses...
github
prashanthvarma/Complex-Networks-Analysis-master
bacon_numbers.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/matlab_bgl/examples/bacon_numbers.m
912
utf_8
640ffeda3bf059842e10b5e204d99888
function bn = bacon_numbers(A,u) % BACON_NUMBERS Compute the Bacon numbers for a graph. % % bn = bacon_numbers(A,u) computes the Bacon numbers for all nodes in the % graph assuming that Kevin Bacon is node u. % allocate storage for the bacon numbers % the ipdouble call allocates storage that can be modified in place....
github
prashanthvarma/Complex-Networks-Analysis-master
rtest_1.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/matlab_bgl/test/rtest_1.m
1,767
utf_8
591edf7b20b839883d608054412f6829
function rval=rtest_1() n = 49; [A,b] = testmat(n,2); x0 = [1:n]'/(n+1); y0 = [1:n]'/(n+1); x = repmat(x0,1,n); y = repmat(y0',n,1); xy = [x(:),y(:)]; rval = 0; try T = mst(A); T = T + diag(diag(A)); rval = 1; catch lasterr end; try A(1,2)= -1; A(2,1)= -1; T = prim_mst(A); rval ...
github
prashanthvarma/Complex-Networks-Analysis-master
rtest_6.m
.m
Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/matlab_bgl/test/rtest_6.m
609
utf_8
eb8fb5b91bb3daf03c595491cc14de96
function rval = rtest_6() rval = 0; try % create a line graph n = 10; A = sparse(1:n-1,2:n,1,n,n); A = A+A'; u = 1; v = 5; d = dist_uv(A,u,v); if any(d(v+1:end) > 0) error('breadth_first_search did not stop correctly'); end rval = 1; catch lasterr end end...
github
prashanthvarma/Complex-Networks-Analysis-master
kmin_neighbors.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 3/Code/kmin_neighbors.m
542
utf_8
f02d9ee6a2689ef31cba4541c74be12e
% Finds the number of "kmin"-neighbors (k links away at a minimum) for every node % If nodes are k-links away due to loops (so they appear as m-neighbours, m<k), they are not counted % INPUTS: adjacency matrix, node index, k - number of links % OUTPUTS: vector of "kmin"-neighbors indices % GB, May 16, 2011 function kn...
github
prashanthvarma/Complex-Networks-Analysis-master
distance_distribution.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 3/Code/distance_distribution.m
803
utf_8
20ab339d624338f2a9b279c42df51ddd
% The number of pairs of nodes at a distance x, divided by the total number of pairs n(n-1) % Source: Mahadevan et al, "Systematic Topology Analysis and Generation Using Degree Correlations" % Note: The cumulative distance distribution (hop-plot) can be obtained by using ddist(i)=length(find(dij<=i)); in line 18 inste...
github
prashanthvarma/Complex-Networks-Analysis-master
astar_search.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 3/Code/astar_search.m
3,582
utf_8
528ff641877279dc012bed23ea2d9d21
function [d pred f]=astar_search(A,s,h,varargin) % ASTAR_SEARCH Perform a heuristically guided (A*) search on the graph. % % [d pred rank]=astar_search(A,s,h,optionsu) returns the distance map, % search tree and f-value of each node in an astar_search. % The search begins at vertex s. The heuristic h guides the searc...