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
edgeL2adjL.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 3/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 5/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 5/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 5/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
closeness.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 5/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 ...
github
prashanthvarma/Complex-Networks-Analysis-master
PriceModel.m
.m
Complex-Networks-Analysis-master/Assignment/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/Code/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/Exercise 5/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 5/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 5/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 5/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