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
num_conn_comp.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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
radial_plot.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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
path_histogram.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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/Exercise 2/Code/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 4/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 4/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 4/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...
github
prashanthvarma/Complex-Networks-Analysis-master
rewire_assort.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/rewire_assort.m
1,285
utf_8
50bed6900e436bbf3a8619ab5f5d2c39
% Degree-preserving random rewiring % Every rewiring increases 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
closeness.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/closeness.m
583
utf_8
2d726747852d36fe9860055241eba9d9
% Computes the closeness centrality for every vertex: 1/sum(dist to all other nodes) % For disconnected graphs can use: sum_over_t(2^-d(i,t)), idea Dangalchev (2006) % C(i)=sum(2.^(-d)) if graph is disconnected, but sum w/o d(i) % INPUTs: graph representation (adjacency matrix nxn) % OUTPUTs: vector of centralities, nx...
github
prashanthvarma/Complex-Networks-Analysis-master
pdf_cdf_rank.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/pdf_cdf_rank.m
1,109
utf_8
0c22030962884c353715e29b2901273b
% Compute the pdf, cdf and rank distributions for a sequence of values % INPUTS: sequence of values: x, size 1xn, 'plot' - 'on' or 'off' % OUTPUTS: pdf, cdf and rank distribution values % Note: pdf = frequency, cdf = cumulative frequency, rank = log-log scale of the sorted sequence % GB, Last Updated: June 27, 2007 fu...
github
prashanthvarma/Complex-Networks-Analysis-master
getEdges.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/getEdges.m
889
utf_8
08031761752379ee53bc6809359690d7
% Return the list of edges for varying representation types % Inputs: graph structure (matrix or cell or struct) and type of structure (string) % Outputs: edge list % 'type' can be: 'adj','edgelist','adjlist' (neighbor list),'inc' (incidence matrix) % Note: symmetric edges will both twice, also in undirected graphs, (i...
github
prashanthvarma/Complex-Networks-Analysis-master
node_betweenness_slow.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/node_betweenness_slow.m
1,066
utf_8
5f8168b479a5b61c967cbf627b10961c
% Betweenness centrality measure: number of shortest paths running though a % vertex. Compute for all vertices. % Note: Valid for a general graph. Using 'number of shortest paths through a node' definition % INPUTS: adjacency (distances) matrix (nxn) % OUTPUTS: betweeness vector for all vertices (nx1) % % GB, Oct...
github
prashanthvarma/Complex-Networks-Analysis-master
louvain_community_finding.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/louvain_community_finding.m
3,058
utf_8
f2982cf49fcdc343214336347a463879
% Implementation of a community finding algorithm by Blondel et al % Source: "Fast unfolding of communities in large networks", July 2008 % https://sites.google.com/site/findcommunities/ % Note: This is just the first step of the Louvain community % finding algorithm, to extract fewer communities, need to repeat with t...
github
prashanthvarma/Complex-Networks-Analysis-master
subgraph.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/subgraph.m
330
utf_8
4ba2f72c47d99789be72f75e8364658a
% This function outputs the adjacency matrix of a subgraph given the % supergraph and the node set of the subgraph % INPUTs: adj - supergraph adjacency matrix, S - vector of subgraph node indices % OUTPUTs: adj_sub - adjacency matrix of the subgraph % GB, January 5, 2006 function adj_sub = subgraph(adj,S) adj_sub = ...
github
prashanthvarma/Complex-Networks-Analysis-master
fabrikant_model.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/fabrikant_model.m
1,566
utf_8
93627d3d44a3bf2c9fd15a1d26166500
% Implements the Fabrikant model of internet growth % Source: Fabrikant et al, "Heuristically Optimized Trade-offs: A New Paradigm for Power Laws in the Internet" % Note: Assume the first point to be the center - easy to change by setting p(1,:) = [x0,y0] % INPUTS: n - number of points, parameter alpha, [0,inf), plt='o...
github
prashanthvarma/Complex-Networks-Analysis-master
loops4.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/loops4.m
1,091
utf_8
c5ed30f9a6713c0e726abd5d96d1b34e
% Finds loops of length 4 in a graph; Note: Quite basic and slow, but works % INPUTs: adj - adjacency matrix of graph % OUTPUTs: number of loops of size 4 % Note: assumes undirected graph % Other functions used: adj2adjL.m % Last Updated: May 25, 2010, originally April 2006 function l4 = loops4(adj) n = size(adj,1); ...
github
prashanthvarma/Complex-Networks-Analysis-master
graph_from_degree_sequence.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/graph_from_degree_sequence.m
617
utf_8
d25557ddc5bbe8caec9cdf70d155f1b8
% Constructing a graph from a given degree sequence: deterministic % This is the Havel-Hakimi algorithm % Inputs: a graphic degree sequence, [d1,d2, ... dn], where di is the degree of the ith node % Outputs: adjacency matrix, nxn function adj = graph_from_degree_sequence(seq) adj = zeros(length(seq)); while sum(seq)...
github
prashanthvarma/Complex-Networks-Analysis-master
shortest_pathDP.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/shortest_pathDP.m
1,211
utf_8
64f76e40106bdfb150b64eb984d86d4e
% Shortest path algorithm using Dynamic Programming % Valid for directed/undirected network % Disclaimer: if links have weights, they are treated as distances % INPUTs: L - (cost/path lengths matrix), s - (start/source node), t - (end/destination node) % OUTPUTS: % route - sequence of nodes on optimal path, at c...
github
prashanthvarma/Complex-Networks-Analysis-master
newman_eigenvector_method.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/newman_eigenvector_method.m
2,449
utf_8
c644c0965473981204128ef8e7a0acd6
% Find the "optimal" number of communities given a network using an eigenvector method % Source: MEJ Newman: Finding community structure using the eigenvectors of matrices, arXiv:physics/0605087 % Newman, "Modularity and community structure in networks", arxiv.org/pdf/physics/0602124v1 % Q=(s^T)Bs, Bij=Aij-kikj/2m % Bi...
github
prashanthvarma/Complex-Networks-Analysis-master
isbipartite.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/isbipartite.m
1,187
utf_8
c2cca322f3915127fbd714a012363f29
% Test whether a graph is bipartite, if yes, return the two vertex sets % Inputs: graph in the form of adjancency list (neighbor list, see adj2adjL.m) % Outputs: True/False (boolean), empty set (if False) or two sets of vertices % Note: This only works for undirected graphs % Last updated: April 28, 2011 function [isi...
github
prashanthvarma/Complex-Networks-Analysis-master
iseulerian.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/iseulerian.m
847
utf_8
05fd6318292b4d14184b0a0f897bc58e
% Check if a graph is Eulerian, i.e. it has an Eulerian circuit % "A connected undirected graph is Eulerian if and only if every graph vertex has an even degree." % "A connected directed graph is Eulerian if and only if every graph vertex has equal in- and out- degree." % Note: Assume that the graph is connected. % INP...
github
prashanthvarma/Complex-Networks-Analysis-master
kregular.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/kregular.m
1,471
utf_8
1c1c4b70c88e6e91315f10f8f920ae67
% Create a k-regular graph % INPUTs: n - # nodes, k - degree of each vertex % OUTPUTs: el - edge list of the k-regular undirected graph % GB, Last updated: January 12, 2011 function eln = kregular(n,k) el={}; if k>n-1; fprintf('a simple graph with n nodes and k>n-1 does not exist\n'); return; end if mod(k,2)==1 & mo...
github
prashanthvarma/Complex-Networks-Analysis-master
laplacian_matrix.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/laplacian_matrix.m
605
utf_8
d71625ae2828704dba7f77756190e5ca
% The Laplacian matrix defined for a *simple* graph % (the difference b/w the diagonal degree and the adjacency matrices) % Note: This is not the normalized Laplacian % INPUTS: adjacency matrix % OUTPUTs: Laplacian matrix function L=laplacian_matrix(adj) L=diag(sum(adj))-adj; % NORMALIZED Laplacian ============= ...
github
prashanthvarma/Complex-Networks-Analysis-master
iscomplete.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/iscomplete.m
453
utf_8
946fe6b7530f0d9bf2613bff525fb3a7
% Checks whether a (sub)graph is complete, i.e. whether every node is % linked to every other node. Only defined for unweighted graphs. % INPUTS: adjacency matrix, adj, nxn % OUTPUTS: Boolean variable, true/false % GB, Last Updated: October 1, 2009 function S=iscomplete(adj) S=false; % default adj=adj>0; % remove w...
github
prashanthvarma/Complex-Networks-Analysis-master
master_equation_growth_model.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/master_equation_growth_model.m
1,103
utf_8
fd280633ec899bb361cf320177cc28ac
% "Master equation" growth model, as in "Evolution of Networks" by Dorogovtsev, Mendez % Note: probability of attachment: (q(i)+ma)/((1+a)mt), q(i)-indegree of i, a=const, t - time step (# nodes) % INPUTS: number of nodes n, m - # links to add at each step, a=constant % OUTPUTS: adjacency matrix, nxn % Last updated by ...
github
prashanthvarma/Complex-Networks-Analysis-master
symmetrize.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/symmetrize.m
292
utf_8
bc8994ec798d3780fca60fee20d06f4b
% Symmetrize a non-symmetric matrix % For matrices in which mat(i,j)~=mat(j,i), the larger (nonzero) value is chosen % INPUTS: a matrix - nxn % OUTPUT: corresponding symmetric matrix - nxn % Last Updated: October 1, 2009 function adj_sym = symmetrize(adj) adj_sym = max(adj,transpose(adj));
github
prashanthvarma/Complex-Networks-Analysis-master
preferential_attachment.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/preferential_attachment.m
1,453
utf_8
a9e6c6b9678bcdd62ed7391151d0d2b9
% Routine implementing a simple preferential attachment (B-A) model for network growth % The probability that a new vertex attaches to a given old vertex is proportional to the (total) vertex degree % Vertices arrive one at a time % INPUTs: n - final (desired) number of vertices, m - # edges to attach at every step % O...
github
prashanthvarma/Complex-Networks-Analysis-master
rewire.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/rewire.m
1,573
utf_8
c76d6462de35d66608c1a8c22edbee35
% Degree-preserving random rewiring % Note 1: Assume unweighted undirected graph % INPUTS: edgelist, el (mx3) and number of rewirings, k % OUTPUTS: rewired edgelist function el = rewire(el,k) rew=0; while rew<k % pick two random edges ind = randi(length(el),1,2); edge1=el(ind(1),:); edge2=el(ind(2),:); ...
github
prashanthvarma/Complex-Networks-Analysis-master
pajek2edgeL.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/pajek2edgeL.m
903
utf_8
409dcc303d61e9f3d5f30620fff04847
% This program extracts an edge list from a pajek text (.net) file % INPUT: .net (or .txt) filename, n - number of nodes in the graph % OUTPUT: edge list, mx3, m - # edges % GB, October 7, 2009 function el=pajek2edgeL(filename,n) [e1,e2,e3] = textread(filename,'%6d%6d%6d','headerlines',n+2); el=[e1,e2,e3]; % ALTERNA...
github
prashanthvarma/Complex-Networks-Analysis-master
graph_energy.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/graph_energy.m
364
utf_8
6f654d7fa6023413fa7374f035722f00
% Graph energy defined as: the sum of the absolute values of the real components of the eigenvalues % Source: Gutman, The energy of a graph, Ber. Math. Statist. Sekt. Forsch-ungszentram Graz. 103 (1978) 1?22. % INPUTs: adjacency matrix (nxn) % OUTPUTs: graph energy function G=graph_energy(adj) [~,e]=eig(adj); % e ar...
github
prashanthvarma/Complex-Networks-Analysis-master
edgeL2cyto.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/edgeL2cyto.m
659
utf_8
9c5a5753b03e8b4b5989655914d3ef83
% Write an edgelist structure m x [node 1, node 2, link] to Cytoscape input format (.txt or any text extension works) % In Cytoscape the column separator option is semi-colon ";". If desired, this is easy to change below in line 15. % INPUTs: edgelist - mx3 matrix, m = number of edges, file name string % OUTPUTs: text ...
github
prashanthvarma/Complex-Networks-Analysis-master
add_edge_weights.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/add_edge_weights.m
637
utf_8
a985e07602ef4a8cd5f2420091995fbe
% Add multiple edges in an edgelist % INPUTS: original (non-compact) edgelist % OUTPUTS: final compact edgelist (no row repetitions) % GB, Last updated: October 7, 2009 function elc=add_edge_weights(el) el2=[el(:,1), el(:,2)]; % make the edge list searchable w/o the weights visited=[]; % mark visited edge...
github
prashanthvarma/Complex-Networks-Analysis-master
leaf_nodes.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/leaf_nodes.m
461
utf_8
79836b7b803d42f6375d4b281441906d
% Return the leaf nodes of the graph - degree 1 nodes % Note: For a directed graph, leaf nodes are those with a single incoming edge % Note 2: There could be other definitions of leaves ex: farthest away from a given root node % Note 3: Nodes with self-loops are not considered leaf nodes. % Input: adjacency matrix % Ou...
github
prashanthvarma/Complex-Networks-Analysis-master
dot_matrix_plot.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/dot_matrix_plot.m
1,917
utf_8
f54e10363b5c6f53457d53c2d9c0d364
% Draws the matrix as a column/row sorted square dot-matrix pattern % INPUTs: adj - adjacency matrix representation of the graph % OUTPUTs: plot % Note: Change colors and marker types in lines 41, 48, 55 and 62 % Other routines used: degrees.m, sort_nodes_by_max_neighbor_degree.m, % eigencentrality...
github
prashanthvarma/Complex-Networks-Analysis-master
smooth_diameter.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/smooth_diameter.m
984
iso_8859_13
26dc10da73ca56920dbfac06ab58fca4
% A relaxed/smoothed definition of diameter: the number "d" at which % a threshold fraction "p" of pairs of nodes are at distance at most % "d". Can be non-integer using interpolation. % Idea: Leskovec et al, "Graphs over Time: Densification Laws, Shrinking Diameters and Possible Explanations" % Input: adjacency matrix ...
github
prashanthvarma/Complex-Networks-Analysis-master
ave_neighbor_deg.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/ave_neighbor_deg.m
591
utf_8
ec6df6502dc82cbfc5b71e4c6a0145ed
% Computes the average degree of neighboring nodes for every vertex % Note: Works for weighted degrees also % INPUTs: adjacency matrix % OUTPUTs: average neighbor degree vector nx1 % Other routines used: degrees.m, kneighbors.m % GB, Last updated: May 21, 2010 function ave_n_deg=ave_neighbor_deg(adj) ave_n_deg=zeros(...
github
prashanthvarma/Complex-Networks-Analysis-master
edgeL2adj.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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
grid_graph.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/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
average_degree.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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/Exercise 4/Code/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 ...