File: Node.h

package info (click to toggle)
rdkit 202503.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 220,160 kB
  • sloc: cpp: 399,240; python: 77,453; ansic: 25,517; java: 8,173; javascript: 4,005; sql: 2,389; yacc: 1,565; lex: 1,263; cs: 1,081; makefile: 580; xml: 229; fortran: 183; sh: 105
file content (135 lines) | stat: -rw-r--r-- 2,733 bytes parent folder | download | duplicates (2)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//
//
//  Copyright (C) 2020 Schrödinger, LLC
//
//   @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//
#pragma once

#include <vector>

#include "Descriptor.h"
#include "Mancude.h"
#include "Edge.h"

namespace RDKit {

class Atom;

namespace CIPLabeler {

class Digraph;

class Node {
 public:
  /**
   * Flag indicates whether the node has been expanded.
   */
  static const int EXPANDED = 0x1;

  /**
   * Flag indicates whether the node was duplicated
   * at a ring closure.
   */
  static const int RING_DUPLICATE = 0x2;

  /**
   * Flag indicates whether the node was duplicated
   * at a bond with order &gt; 1.
   */
  static const int BOND_DUPLICATE = 0x4;

  /**
   * Mask to check if a node is duplicated.
   */

  static const int DUPLICATE = RING_DUPLICATE | BOND_DUPLICATE;

  /**
   * Node was created for an implicit hydrogen,
   * the 'atom' value will be null.
   */
  static const int IMPL_HYDROGEN = 0x8;

  /**
   * Mask to check if a node is duplicated or created for an implicit H (not a
   * primary node).
   */
  static const int DUPLICATE_OR_H =
      RING_DUPLICATE | BOND_DUPLICATE | IMPL_HYDROGEN;

  Node() = delete;
  Node(const Node &) = delete;
  Node &operator=(const Node &) = delete;

  Node(Digraph *g, std::vector<char> &&visit, Atom *atom,
       boost::rational<int> &&frac, int dist, int flags);

  Digraph *getDigraph() const;

  Atom *getAtom() const;

  int getDistance() const;

  boost::rational<int> getAtomicNumFraction() const;

  int getAtomicNum() const;

  unsigned getMassNum() const;

  double getAtomicMass() const;

  Descriptor getAux() const;

  bool isSet(int mask) const;

  bool isDuplicate() const;

  bool isDuplicateOrH() const;

  bool isTerminal() const;

  bool isExpanded() const;

  bool isVisited(int idx) const;

  Node *newChild(int idx, Atom *atom) const;

  Node *newBondDuplicateChild(int idx, Atom *atom) const;

  Node *newRingDuplicateChild(int idx, Atom *atom) const;

  Node *newImplicitHydrogenChild() const;

  void add(Edge *e);

  void setAux(Descriptor desc);

  const std::vector<Edge *> &getEdges() const;

  std::vector<Edge *> getEdges(Atom *end) const;

  std::vector<Edge *> getNonTerminalOutEdges() const;

 private:
  Digraph *dp_g;
  Atom *dp_atom;
  int d_dist;
  boost::rational<int> d_atomic_num;
  double d_atomic_mass;
  Descriptor d_aux = Descriptor::NONE;
  int d_flags = 0x0;

  std::vector<Edge *> d_edges;

  std::vector<char> d_visit;

  Node *newTerminalChild(int idx, Atom *atom, int flags) const;
};

}  // namespace CIPLabeler
}  // namespace RDKit