Files
agent_compositor_test/references/igraph-1.0.1/doc/html/igraph-HRG.html
T
Abdelrahman Said a11edf0c53 Add graph references
2026-06-28 13:49:01 +01:00

1068 lines
38 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 27. Hierarchical random graphs</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="igraph Reference Manual">
<link rel="up" href="index.html" title="igraph Reference Manual">
<link rel="prev" href="igraph-Graphlets.html" title="Chapter 26. Graphlets">
<link rel="next" href="igraph-Embedding.html" title="Chapter 28. Embedding of graphs">
<script type="text/javascript" src="toggle.js"></script><link rel="stylesheet" href="style.css" type="text/css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css">
<link rel="chapter" href="igraph-Introduction.html" title="Chapter 1. Introduction">
<link rel="chapter" href="igraph-Installation.html" title="Chapter 2. Installation">
<link rel="chapter" href="igraph-Tutorial.html" title="Chapter 3. Tutorial">
<link rel="chapter" href="igraph-Basic.html" title="Chapter 4. Basic data types and interface">
<link rel="chapter" href="igraph-Error.html" title="Chapter 5. Error handling">
<link rel="chapter" href="igraph-Memory.html" title="Chapter 6. Memory (de)allocation">
<link rel="chapter" href="igraph-Data-structures.html" title="Chapter 7. Data structure library: vector, matrix, other data types">
<link rel="chapter" href="igraph-Random.html" title="Chapter 8. Random numbers">
<link rel="chapter" href="igraph-Iterators.html" title="Chapter 9. Vertex and edge selectors and sequences, iterators">
<link rel="chapter" href="igraph-Attributes.html" title="Chapter 10. Graph, vertex and edge attributes">
<link rel="chapter" href="igraph-Generators.html" title="Chapter 11. Deterministic graph generators">
<link rel="chapter" href="igraph-Games.html" title='Chapter 12. Stochastic graph generators ("games")'>
<link rel="chapter" href="igraph-Bipartite.html" title="Chapter 13. Bipartite, i.e. two-mode graphs">
<link rel="chapter" href="igraph-Spatial.html" title="Chapter 14. Spatial graphs">
<link rel="chapter" href="igraph-Operators.html" title="Chapter 15. Graph operators">
<link rel="chapter" href="igraph-Visitors.html" title="Chapter 16. Graph visitors">
<link rel="chapter" href="igraph-Structural.html" title="Chapter 17. Structural properties of graphs">
<link rel="chapter" href="igraph-Cycles.html" title="Chapter 18. Graph cycles">
<link rel="chapter" href="igraph-Cliques.html" title="Chapter 19. Cliques and independent vertex sets">
<link rel="chapter" href="igraph-Motifs.html" title="Chapter 20. Graph motifs, dyad census and triad census">
<link rel="chapter" href="igraph-Isomorphism.html" title="Chapter 21. Graph isomorphism">
<link rel="chapter" href="igraph-Coloring.html" title="Chapter 22. Graph coloring">
<link rel="chapter" href="igraph-Flows.html" title="Chapter 23. Maximum flows, minimum cuts and related measures">
<link rel="chapter" href="igraph-Separators.html" title="Chapter 24. Vertex separators">
<link rel="chapter" href="igraph-Community.html" title="Chapter 25. Detecting community structure">
<link rel="chapter" href="igraph-Graphlets.html" title="Chapter 26. Graphlets">
<link rel="chapter" href="igraph-HRG.html" title="Chapter 27. Hierarchical random graphs">
<link rel="chapter" href="igraph-Embedding.html" title="Chapter 28. Embedding of graphs">
<link rel="chapter" href="igraph-Layout.html" title="Chapter 29. Generating layouts for graph drawing">
<link rel="chapter" href="igraph-Processes.html" title="Chapter 30. Processes on graphs">
<link rel="chapter" href="igraph-Foreign.html" title="Chapter 31. Reading and writing graphs from and to files">
<link rel="chapter" href="igraph-Linalg.html" title="Chapter 32. Using BLAS, LAPACK and ARPACK for igraph matrices and graphs">
<link rel="chapter" href="igraph-Nongraph.html" title="Chapter 33. Non-graph related functions">
<link rel="chapter" href="igraph-Advanced.html" title="Chapter 34. Advanced igraph programming">
<link rel="chapter" href="igraph-Glossary.html" title="Chapter 35. Glossary">
<link rel="chapter" href="igraph-Licenses.html" title="Chapter 36. Licenses for igraph and this manual">
<link rel="index" href="ix01.html" title="Index">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navigation-header mb-4" width="100%" summary="Navigation header"><div class="btn-group">
<a accesskey="p" class="btn btn-light" href="igraph-Graphlets.html"><i class="fa fa-chevron-left"></i>
Previous
</a><a accesskey="h" class="btn btn-light" href="index.html"><i class="fa fa-home"></i>
Home
</a><a accesskey="n" class="btn btn-light" href="igraph-Embedding.html"><i class="fa fa-chevron-right"></i>
Next
</a>
</div></div>
<div class="chapter">
<div class="titlepage"><div><div><h1 class="title">
<a name="igraph-HRG"></a>Chapter 27. Hierarchical random graphs</h1></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-HRG.html#hrg-intro">1. Introduction</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#representing-hrgs">2. Representing HRGs</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#fitting-hrgs">3. Fitting HRGs</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#hrg-sampling">4. HRG sampling</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#conversion-to-and-from-igraph-graphs">5. Conversion to and from igraph graphs</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#predicting-missing-edges">6. Predicting missing edges</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#hrg-deprecated">7. Deprecated functions</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="hrg-intro"></a>1.  Introduction</h2></div></div></div>
<p>A hierarchical random graph is an ensemble of undirected
graphs with <code class="constant">n</code> vertices. It is defined via a binary tree with <code class="constant">n</code> leaf and <code class="constant">n-1</code> internal vertices, where the
internal vertices are labeled with probabilities.
The probability that two vertices are connected in the random graph
is given by the probability label at their closest common
ancestor.
</p>
<p>Please read the following two articles for more about
hierarchical random graphs: A. Clauset, C. Moore, and M.E.J. Newman.
Hierarchical structure and the prediction of missing links in networks.
Nature 453, 98 - 101 (2008); and A. Clauset, C. Moore, and M.E.J. Newman.
Structural Inference of Hierarchies in Networks. In E. M. Airoldi
et al. (Eds.): ICML 2006 Ws, Lecture Notes in Computer Science
4503, 1-13. Springer-Verlag, Berlin Heidelberg (2007).
</p>
<p>
igraph contains functions for fitting HRG models to a given network
(<a class="link" href="igraph-HRG.html#igraph_hrg_fit" title="3.1. igraph_hrg_fit — Fit a hierarchical random graph model to a network."><code class="function">igraph_hrg_fit</code></a>), for generating networks from a given HRG
ensemble (<a class="link" href="igraph-HRG.html#igraph_hrg_game" title="4.2. igraph_hrg_game — Generate a hierarchical random graph."><code class="function">igraph_hrg_game</code></a>, <a class="link" href="igraph-HRG.html#igraph_hrg_sample" title="4.1. igraph_hrg_sample — Sample from a hierarchical random graph model."><code class="function">igraph_hrg_sample</code></a>), converting
an igraph graph to a HRG and back (<a class="link" href="igraph-HRG.html#igraph_hrg_create" title="5.2. igraph_hrg_create — Create a HRG from an igraph graph."><code class="function">igraph_hrg_create</code></a>, <a class="link" href="igraph-HRG.html#igraph_hrg_dendrogram" title="7.1. igraph_hrg_dendrogram — Create a dendrogram from a hierarchical random graph."><code class="function">igraph_hrg_dendrogram</code></a>), for calculating a consensus tree from a
set of sampled HRGs (<a class="link" href="igraph-HRG.html#igraph_hrg_consensus" title="3.2. igraph_hrg_consensus — Calculate a consensus tree for a HRG."><code class="function">igraph_hrg_consensus</code></a>) and for predicting
missing edges in a network based on its HRG models (<a class="link" href="igraph-HRG.html#igraph_hrg_predict" title="6.1. igraph_hrg_predict — Predict missing edges in a graph, based on HRG models."><code class="function">igraph_hrg_predict</code></a>).
</p>
<p>The igraph HRG implementation is heavily based on the code
published by Aaron Clauset, at his website,
<a class="ulink" href="https://aaronclauset.github.io/hierarchy/" target="_top">https://aaronclauset.github.io/hierarchy/</a>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="representing-hrgs"></a>2. Representing HRGs</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_t">2.1. <code class="function">igraph_hrg_t</code> — Data structure to store a hierarchical random graph.</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_init">2.2. <code class="function">igraph_hrg_init</code> — Allocate memory for a HRG.</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_destroy">2.3. <code class="function">igraph_hrg_destroy</code> — Deallocate memory for an HRG.</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_size">2.4. <code class="function">igraph_hrg_size</code> — Returns the size of the HRG, the number of leaf nodes.</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_resize">2.5. <code class="function">igraph_hrg_resize</code> — Resize a HRG.</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_t"></a>2.1. <code class="function">igraph_hrg_t</code> — Data structure to store a hierarchical random graph.</h3></div></div></div>
<a class="indexterm" name="id-1.28.3.2.2"></a><p>
</p>
<pre class="programlisting">
typedef struct igraph_hrg_t {
igraph_vector_int_t left;
igraph_vector_int_t right;
igraph_vector_t prob;
igraph_vector_int_t vertices;
igraph_vector_int_t edges;
} igraph_hrg_t;
</pre>
<p>
</p>
<p>
</p>
<p>A hierarchical random graph (HRG) can be given as a binary tree,
where the internal vertices are labeled with real numbers.
</p>
<p>Note that you don't necessarily have to know this
internal representation for using the HRG functions, just pass the
HRG objects created by one igraph function, to another igraph
function.
</p>
<p>
It has the following members:
</p>
<p><b>Values: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="constant">left</code>:</span></p></td>
<td><p>
Vector that contains the left children of the internal
tree vertices. The first vertex is always the root vertex, so
the first element of the vector is the left child of the root
vertex. Internal vertices are denoted with negative numbers,
starting from -1 and going down, i.e. the root vertex is
-1. Leaf vertices are denoted by non-negative number, starting
from zero and up.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">right</code>:</span></p></td>
<td><p>
Vector that contains the right children of the
vertices, with the same encoding as the <code class="constant">left</code> vector.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">prob</code>:</span></p></td>
<td><p>
The connection probabilities attached to the internal
vertices, the first number belongs to the root vertex
(i.e. internal vertex -1), the second to internal vertex -2,
etc.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">edges</code>:</span></p></td>
<td><p>
The number of edges in the subtree below the given
internal vertex.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="constant">vertices</code>:</span></p></td>
<td><p>
The number of vertices in the subtree below the
given internal vertex, including itself.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_init"></a>2.2. <code class="function">igraph_hrg_init</code> — Allocate memory for a HRG.</h3></div></div></div>
<a class="indexterm" name="id-1.28.3.3.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_hrg_init(igraph_hrg_t *hrg, igraph_int_t n);
</pre></div>
<p>
</p>
<p>
This function must be called before passing an <a class="link" href="igraph-HRG.html#igraph_hrg_t" title="2.1. igraph_hrg_t — Data structure to store a hierarchical random graph."><code class="function">igraph_hrg_t</code></a> to
an igraph function.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
Pointer to the HRG data structure to initialize.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em>:</span></p></td>
<td><p>
The number of vertices in the graph that is modeled by
this HRG. It can be zero, if this is not yet known.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), the number of vertices in the graph.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_destroy"></a>2.3. <code class="function">igraph_hrg_destroy</code> — Deallocate memory for an HRG.</h3></div></div></div>
<a class="indexterm" name="id-1.28.3.4.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
void igraph_hrg_destroy(igraph_hrg_t *hrg);
</pre></div>
<p>
</p>
<p>
The HRG data structure can be reinitialized again with an <a class="link" href="igraph-HRG.html#igraph_hrg_destroy" title="2.3. igraph_hrg_destroy — Deallocate memory for an HRG."><code class="function">igraph_hrg_destroy</code></a> call.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
Pointer to the HRG data structure to deallocate.</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: operating system dependent.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_size"></a>2.4. <code class="function">igraph_hrg_size</code> — Returns the size of the HRG, the number of leaf nodes.</h3></div></div></div>
<a class="indexterm" name="id-1.28.3.5.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_int_t igraph_hrg_size(const igraph_hrg_t *hrg);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
Pointer to the HRG.
</p></td>
</tr></tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
The number of leaf nodes in the HRG.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(1).
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_resize"></a>2.5. <code class="function">igraph_hrg_resize</code> — Resize a HRG.</h3></div></div></div>
<a class="indexterm" name="id-1.28.3.6.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_hrg_resize(igraph_hrg_t *hrg, igraph_int_t newsize);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
Pointer to an initialized (see <a class="link" href="igraph-HRG.html#igraph_hrg_init" title="2.2. igraph_hrg_init — Allocate memory for a HRG."><code class="function">igraph_hrg_init</code></a>)
HRG.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>newsize</code></em>:</span></p></td>
<td><p>
The new size, i.e. the number of leaf nodes.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), n is the new size.
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="fitting-hrgs"></a>3. Fitting HRGs</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_fit">3.1. <code class="function">igraph_hrg_fit</code> — Fit a hierarchical random graph model to a network.</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_consensus">3.2. <code class="function">igraph_hrg_consensus</code> — Calculate a consensus tree for a HRG.</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_fit"></a>3.1. <code class="function">igraph_hrg_fit</code> — Fit a hierarchical random graph model to a network.</h3></div></div></div>
<a class="indexterm" name="id-1.28.4.2.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_hrg_fit(const igraph_t *graph,
igraph_hrg_t *hrg,
igraph_bool_t start,
igraph_int_t steps);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The igraph graph to fit the model to. Edge directions
are ignored in directed graphs.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
Pointer to an initialized HRG, the result of the fitting
is stored here. It can also be used to pass a HRG to the
function, that can be used as the starting point of the Markov
Chain Monte Carlo fitting, if the <em class="parameter"><code>start</code></em> argument is true.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>start</code></em>:</span></p></td>
<td><p>
Whether to start the fitting from the given
HRG model.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>steps</code></em>:</span></p></td>
<td><p>
Integer, the number of MCMC steps to take in the
fitting procedure. If this is zero, then the fitting stops if a
convergence criteria is fulfilled.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: TODO.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_consensus"></a>3.2. <code class="function">igraph_hrg_consensus</code> — Calculate a consensus tree for a HRG.</h3></div></div></div>
<a class="indexterm" name="id-1.28.4.3.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_hrg_consensus(const igraph_t *graph,
igraph_vector_int_t *parents,
igraph_vector_t *weights,
igraph_hrg_t *hrg,
igraph_bool_t start,
igraph_int_t num_samples);
</pre></div>
<p>
</p>
<p>
The calculation can be started from the given HRG (<em class="parameter"><code>hrg</code></em>), or (if
<em class="parameter"><code>start</code></em> is false), a HRG is first fitted to the given graph.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>parents</code></em>:</span></p></td>
<td><p>
An initialized vector, the results are stored
here. For each vertex, the id of its parent vertex is stored, or
-1, if the vertex is the root vertex in the tree. The first n
vertex IDs (from 0) refer to the original vertices of the graph,
the other IDs refer to vertex groups.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>weights</code></em>:</span></p></td>
<td><p>
Numeric vector, counts the number of times a given
tree split occured in the generated network samples, for each
internal vertices. The order is the same as in <em class="parameter"><code>parents</code></em>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
A hierarchical random graph. It is used as a starting
point for the sampling, if the <em class="parameter"><code>start</code></em> argument is true. It is
modified along the MCMC.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>start</code></em>:</span></p></td>
<td><p>
Whether to use the supplied HRG (in <em class="parameter"><code>hrg</code></em>)
as a starting point for the MCMC.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>num_samples</code></em>:</span></p></td>
<td><p>
The number of samples to generate for creating
the consensus tree.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: TODO.
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="hrg-sampling"></a>4. HRG sampling</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_sample">4.1. <code class="function">igraph_hrg_sample</code> — Sample from a hierarchical random graph model.</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_game">4.2. <code class="function">igraph_hrg_game</code> — Generate a hierarchical random graph.</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_sample"></a>4.1. <code class="function">igraph_hrg_sample</code> — Sample from a hierarchical random graph model.</h3></div></div></div>
<a class="indexterm" name="id-1.28.5.2.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_hrg_sample(const igraph_hrg_t *hrg, igraph_t *sample);
</pre></div>
<p>
</p>
<p>
This function draws a single sample from a hierarchical random graph model.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
A HRG model to sample from
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>sample</code></em>:</span></p></td>
<td><p>
Pointer to an uninitialized graph; the sample is stored here.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: TODO.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_game"></a>4.2. <code class="function">igraph_hrg_game</code> — Generate a hierarchical random graph.</h3></div></div></div>
<a class="indexterm" name="id-1.28.5.3.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_hrg_game(igraph_t *graph,
const igraph_hrg_t *hrg);
</pre></div>
<p>
</p>
<p>
This function is a simple shortcut to <a class="link" href="igraph-HRG.html#igraph_hrg_sample" title="4.1. igraph_hrg_sample — Sample from a hierarchical random graph model."><code class="function">igraph_hrg_sample</code></a>.
It creates a single graph from the given HRG.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
Pointer to an uninitialized graph, the new graph is
created here.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
The hierarchical random graph model to sample from.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: TODO.
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="conversion-to-and-from-igraph-graphs"></a>5. Conversion to and from igraph graphs</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="igraph-HRG.html#igraph_from_hrg_dendrogram">5.1. <code class="function">igraph_from_hrg_dendrogram</code> — Create a graph representation of the dendrogram of a hierarchical random graph model.</a></span></dt>
<dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_create">5.2. <code class="function">igraph_hrg_create</code> — Create a HRG from an igraph graph.</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_from_hrg_dendrogram"></a>5.1. <code class="function">igraph_from_hrg_dendrogram</code> — Create a graph representation of the dendrogram of a hierarchical random graph model.</h3></div></div></div>
<a class="indexterm" name="id-1.28.6.2.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_from_hrg_dendrogram(
igraph_t *graph, const igraph_hrg_t *hrg, igraph_vector_t *prob
);
</pre></div>
<p>
</p>
<p>
Creates the igraph graph equivalent of the dendrogram encoded in an
<a class="link" href="igraph-HRG.html#igraph_hrg_t" title="2.1. igraph_hrg_t — Data structure to store a hierarchical random graph."><code class="function">igraph_hrg_t</code></a> data structure. The probabilities associated to the
nodes are returned in a vector so this function works without an
attribute handler.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
Pointer to an uninitialized graph, the result is
stored here.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
The hierarchical random graph to convert.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>prob</code></em>:</span></p></td>
<td><p>
Pointer to an <span class="emphasis"><em>initialized</em></span> vector; the probabilities
associated to the nodes of the dendrogram will be stored here. Leaf nodes
will have an associated probability of <code class="constant">IGRAPH_NAN</code> .
You may set this to <code class="constant">NULL</code> if you do not need the probabilities.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), the number of vertices in the graph.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_create"></a>5.2. <code class="function">igraph_hrg_create</code> — Create a HRG from an igraph graph.</h3></div></div></div>
<a class="indexterm" name="id-1.28.6.3.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_hrg_create(igraph_hrg_t *hrg,
const igraph_t *graph,
const igraph_vector_t *prob);
</pre></div>
<p>
</p>
<p>
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
Pointer to an initialized <a class="link" href="igraph-HRG.html#igraph_hrg_t" title="2.1. igraph_hrg_t — Data structure to store a hierarchical random graph."><code class="function">igraph_hrg_t</code></a>. The result
is stored here.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The igraph graph to convert. It must be a directed
binary tree, with n-1 internal and n leaf vertices. The root
vertex must have in-degree zero.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>prob</code></em>:</span></p></td>
<td><p>
The vector of probabilities, this is used to label the
internal nodes of the hierarchical random graph.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), the number of vertices in the tree.
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="predicting-missing-edges"></a>6. Predicting missing edges</h2></div></div></div>
<div class="toc"><dl class="toc"><dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_predict">6.1. <code class="function">igraph_hrg_predict</code> — Predict missing edges in a graph, based on HRG models.</a></span></dt></dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_predict"></a>6.1. <code class="function">igraph_hrg_predict</code> — Predict missing edges in a graph, based on HRG models.</h3></div></div></div>
<a class="indexterm" name="id-1.28.7.2.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_hrg_predict(const igraph_t *graph,
igraph_vector_int_t *edges,
igraph_vector_t *prob,
igraph_hrg_t *hrg,
igraph_bool_t start,
igraph_int_t num_samples,
igraph_int_t num_bins);
</pre></div>
<p>
</p>
<p>
Samples HRG models for a network, and estimated the probability
that an edge was falsely observed as non-existent in the network.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
The input graph.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>edges</code></em>:</span></p></td>
<td><p>
The list of missing edges is stored here, the first
two elements are the first edge, the next two the second edge,
etc.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>prob</code></em>:</span></p></td>
<td><p>
Vector of probabilies for the existence of missing
edges, in the order corresponding to <code class="constant">edges</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
A HRG, it is used as a starting point if <code class="constant">start</code> is
true. It is also modified during the MCMC sampling.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>start</code></em>:</span></p></td>
<td><p>
Whether to start the MCMC from the given HRG.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>num_samples</code></em>:</span></p></td>
<td><p>
The number of samples to generate.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>num_bins</code></em>:</span></p></td>
<td><p>
Controls the resolution of the edge
probabilities. Higher numbers result higher resolution.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: TODO.
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="hrg-deprecated"></a>7. Deprecated functions</h2></div></div></div>
<div class="toc"><dl class="toc"><dt><span class="section"><a href="igraph-HRG.html#igraph_hrg_dendrogram">7.1. <code class="function">igraph_hrg_dendrogram</code> — Create a dendrogram from a hierarchical random graph.</a></span></dt></dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="igraph_hrg_dendrogram"></a>7.1. <code class="function">igraph_hrg_dendrogram</code> — Create a dendrogram from a hierarchical random graph.</h3></div></div></div>
<a class="indexterm" name="id-1.28.8.2.2"></a><p>
</p>
<div class="informalexample"><pre class="programlisting">
igraph_error_t igraph_hrg_dendrogram(igraph_t *graph, const igraph_hrg_t *hrg);
</pre></div>
<p>
</p>
<p>
Creates the igraph graph equivalent of an <a class="link" href="igraph-HRG.html#igraph_hrg_t" title="2.1. igraph_hrg_t — Data structure to store a hierarchical random graph."><code class="function">igraph_hrg_t</code></a> data
structure.
</p>
<p><b>Arguments: </b>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>graph</code></em>:</span></p></td>
<td><p>
Pointer to an uninitialized graph, the result is
stored here.
</p></td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>hrg</code></em>:</span></p></td>
<td><p>
The hierarchical random graph to convert.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p><b>Returns: </b></p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code></code></em></span></p></td>
<td><p>
Error code.
</p></td>
</tr></tbody>
</table></div>
<p>
Time complexity: O(n), the number of vertices in the graph.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p>Deprecated since version 0.10.5. Please do not use this function in new
code; use <a class="link" href="igraph-HRG.html#igraph_from_hrg_dendrogram" title="5.1. igraph_from_hrg_dendrogram — Create a graph representation of the dendrogram of a hierarchical random graph model."><code class="function">igraph_from_hrg_dendrogram()</code></a>
instead.</p>
</div>
<p>
</p>
</div>
</div>
</div>
<table class="navigation-footer" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle">
<td align="left"><a accesskey="p" href="igraph-Graphlets.html"><b>← Chapter 26. Graphlets</b></a></td>
<td align="right"><a accesskey="n" href="igraph-Embedding.html"><b>Chapter 28. Embedding of graphs →</b></a></td>
</tr></table>
</body>
</html>