File: atlas.c

package info (click to toggle)
r-cran-igraph 0.7.1-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 14,280 kB
  • sloc: ansic: 150,105; cpp: 19,404; fortran: 3,777; yacc: 1,164; tcl: 931; lex: 484; makefile: 13; sh: 9
file content (82 lines) | stat: -rw-r--r-- 2,738 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* -*- mode: C -*-  */
/* 
   IGraph R package.
   Copyright (C) 2006-2012  Gabor Csardi <csardi.gabor@gmail.com>
   334 Harvard street, Cambridge, MA 02139 USA
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
   02110-1301 USA

*/

#include "igraph_constructors.h"
#include "atlas-edges.h"
#include "config.h"

/**
 * \function igraph_atlas
 * \brief Create a small graph from the \quote Graph Atlas \endquote.
 * 
 * </para><para>
 * The number of the graph is given as a parameter. 
 * The graphs are listed: \olist
 *      \oli in increasing order of number of nodes;
 *      \oli for a fixed number of nodes, in increasing order of the 
 *           number of edges;
 *      \oli for fixed numbers of nodes and edges, in increasing 
 *           order of the degree sequence, for example 111223 &lt; 112222; 
 *      \oli for fixed degree sequence, in increasing number of 
 *           automorphisms.
 *      \endolist
 *
 * </para><para>
 * The data was converted from the NetworkX software package, 
 * see http://networkx.github.io .
 * 
 * </para><para>
 * See \emb An Atlas of Graphs \eme by Ronald C. Read and Robin J. Wilson, 
 * Oxford University Press, 1998.
 * 
 * \param graph Pointer to an uninitialized graph object. 
 * \param number The number of the graph to generate.
 * 
 * Added in version 0.2.</para><para>
 * 
 * Time complexity: O(|V|+|E|), the number of vertices plus the number of 
 * edges.
 * 
 * \example examples/simple/igraph_atlas.c
 */
int igraph_atlas(igraph_t *graph, int number) {
  
  igraph_integer_t pos, n, e;
  igraph_vector_t v=IGRAPH_VECTOR_NULL;

  if (number < 0 ||
      number >= (int) (sizeof(igraph_i_atlas_edges_pos)/sizeof(long int))) {
    IGRAPH_ERROR("No such graph in atlas", IGRAPH_EINVAL);
  }

  pos=(igraph_integer_t) igraph_i_atlas_edges_pos[number];
  n=(igraph_integer_t) igraph_i_atlas_edges[pos];
  e=(igraph_integer_t) igraph_i_atlas_edges[pos+1];
  
  IGRAPH_CHECK(igraph_create(graph, 
			     igraph_vector_view(&v,igraph_i_atlas_edges+pos+2, 
						e*2),  
			     n, IGRAPH_UNDIRECTED));
  
  return 0;
}