RDKit
Open-source cheminformatics and machine learning.
Graph.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2014 Novartis Institutes for BioMedical Research
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 
11 // graph topology in terms of indeces in source molecule
12 #pragma once
13 #include <boost/graph/adjacency_list.hpp>
14 
15 namespace RDKit {
16  namespace FMCS {
17  typedef unsigned AtomIdx_t;
18  typedef unsigned BondIdx_t;
19  typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, AtomIdx_t, BondIdx_t> Graph_t;
20 
21  class Graph : public Graph_t {
22  public:
23  typedef edge_iterator EDGE_ITER;
24  typedef std::pair<EDGE_ITER,EDGE_ITER> BOND_ITER_PAIR;
25 
26  void addAtom(unsigned atom) {
27  Graph::vertex_descriptor which = boost::add_vertex(*this);
28  (*this)[which] = atom;
29  }
30  void addBond(unsigned bond, unsigned beginAtom, unsigned endAtom) {
31  bool res;
32  Graph_t::edge_descriptor which;
33  boost::tie(which, res) = boost::add_edge(beginAtom, endAtom, *this);
34  (*this)[which] = bond;
35  }
36  };
37 
38  }
39 }
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, AtomIdx_t, BondIdx_t > Graph_t
Definition: Graph.h:19
void addAtom(unsigned atom)
Definition: Graph.h:26
std::pair< EDGE_ITER, EDGE_ITER > BOND_ITER_PAIR
Definition: Graph.h:24
void addBond(unsigned bond, unsigned beginAtom, unsigned endAtom)
Definition: Graph.h:30
unsigned AtomIdx_t
Definition: Graph.h:17
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
unsigned BondIdx_t
Definition: Graph.h:18
edge_iterator EDGE_ITER
Definition: Graph.h:23