14 vector<vector<int> > m_nodes;
16 vector<bool> m_visited;
17 typedef vector<vector<int> >::iterator nodeiter;
18 typedef vector<bool>::iterator visititer;
27 AdjList(
int nodes):m_nodes(nodes), m_visited(nodes)
29 for(visititer i = m_visited.begin(); i != m_visited.end();++i)
33 for(nodeiter i = m_nodes.begin(); i != m_nodes.end(); ++i)
47 m_nodes[n1].push_back(n2);
48 m_nodes[n2].push_back(n1);
58 m_visited[node] =
true;
69 return m_visited[node];
79 for(
unsigned int i = 0; i < m_nodes[node].size(); i++)
81 if(!m_visited[m_nodes[node][i]])
83 return m_nodes[node][i];
96 vector<int> ret = vector<int>();
98 for(
unsigned int i = 0; i < m_nodes[node].size(); i++)
100 if(!m_visited[m_nodes[node][i]] )
102 ret.push_back(m_nodes[node][i]);
115 for(
unsigned int i = 0; i < m_nodes.size(); i++)
117 if(m_nodes[i].size() == 1)
132 for(
unsigned int i = 0; i < m_nodes.size(); i++)
134 if(m_nodes[i].size() == 1)
147 for(
unsigned int i = 0; i < m_nodes.size(); i++)
149 cerr <<
" Node " << i <<
":\t";
150 for(
unsigned int j = 0; j < m_nodes[i].size(); j++)
152 cerr << m_nodes[i][j] <<
" ";
vector< int > findAllFirst() const
void adjacent(int n1, int n2)
int findNext(int node) const
bool isVisited(int node) const
vector< int > findAllNext(int node) const