3 using System.Collections.Generic;
13 public List<GraphVertex>
neighbor =
new List<GraphVertex>();
32 public bool SearchCycle(List<int> vertex,
int first,
int size=0){
39 for (
int i=0; i<neighbor.Count; i++){
40 if (neighbor[i].
id==first){
49 if(neighbor[i].flag==
false){
51 if(neighbor[i].
SearchCycle(vertex,first, size+1)==
true){
62 public bool AlreadyAdded(Dictionary <
int,List<int>> connectivityList,
int key,
int atom){
64 if (connectivityList.ContainsKey(key)){
66 for (
int j=0; j<connectivityList[key].Count / 3; j++){
67 if (connectivityList[key][0+(3*j)] == atom)
79 public void addInDict(Dictionary <
int,List<int>> connectivityList,
int ring1,
int atom1,
int ring2,
int atom2){
82 if (connectivityList.ContainsKey(ring1))
83 connectivityList[ring1].AddMany(atom1, ring2, atom2);
85 connectivityList[ring1] =
new List<int>(
new int [] {atom1, ring2, atom2});
90 public bool SearchConnection(Dictionary <
int,List<int>> connectivityList, List<int> trashlist,
int r1=-1,
int size=0){
102 if ((size == 1) && (this.idRing != -1))
108 for (
int i=0; i<neighbor.Count; i++){
109 if (this.idRing != -1){
110 if ((size==2) || (size == 3)){
111 if (this.idRing != r1){
112 trashlist.Add(this.idRing);
113 trashlist.Add(this.
id);
124 if(neighbor[i].flag==
false){
126 if(neighbor[i].
SearchConnection(connectivityList,trashlist, r1, size+1)==
true){
129 int r2 = trashlist[0];
130 int a2 = trashlist[1];
132 addInDict(connectivityList, r1, a1, r2, a2);
134 addInDict(connectivityList, r2, a2, r1, a1);
bool SearchCycle(List< int > vertex, int first, int size=0)
This function will search recursivly a cycle : We "walk" from atom to atom, and if we find the atom w...
bool AlreadyAdded(Dictionary< int, List< int >> connectivityList, int key, int atom)
void addInDict(Dictionary< int, List< int >> connectivityList, int ring1, int atom1, int ring2, int atom2)
List< GraphVertex > neighbor
This class is made to convert an atom (postion X,Y,Z) to a object with a list of neighbor.
bool SearchConnection(Dictionary< int, List< int >> connectivityList, List< int > trashlist, int r1=-1, int size=0)