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 | PriceModel.m | .m | Complex-Networks-Analysis-master/Assignment/Exercise 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 | rewire_disassort.m | .m | Complex-Networks-Analysis-master/Assignment/Exercise 4/Code/rewire_disassort.m | 1,255 | utf_8 | 269669174b4cd7fa67f9dc956c0ea991 | % Degree-preserving random rewiring
% Every rewiring decreases the assortativity (pearson coefficient)
% Note 1: There are rare cases of neutral rewiring (coeff stays the same within numerical error)
% Note 2: Assume unweighted undirected graph
% INPUTS: edgelist, el and number of rewirings, k
% OUTPUTS: rewired edgeli... |
github | prashanthvarma/Complex-Networks-Analysis-master | radial_plot.m | .m | Complex-Networks-Analysis-master/Assignment/Exercise 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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 4/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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 | rewire_assort.m | .m | Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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 | BFS.m | .m | Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/BFS.m | 530 | utf_8 | 002b0227dfd8bfcbca8413aa599cd7ae | % Implementation of breadth-first-search of a graph
% INPUTs: adjacency list, starting node index
% OUTPUTs: BFS tree, in adjacency list format (directed)
function T=BFS(adjL,i0)
discovered=[i0];
q=[i0];
T=cell(length(adjL),1);
while not(isempty(q))
j=q(1); q=q(2:length(q)); % pop the front
neigh=adjL{j};
... |
github | prashanthvarma/Complex-Networks-Analysis-master | pdf_cdf_rank.m | .m | Complex-Networks-Analysis-master/Assignment/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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/Network & Graph Matlab Packages/MIT_Network Analysis/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(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.