主题:帮忙看段代码的片断,问个简单逻辑问题
跟二分图有关,但只是个逻辑问题,谢谢指教
struct Edge //这是对于边"Edge"的结构定义
{
int to;
Edge* next;
Edge(int _to) { to = _to; }
};
void addEdge(int left, int right) //在左顶点left和右顶点right之间添加边
{
if (!m_matrix[left][right]) //m_matrix[][]是检验是否已有边相连
{
m_matrix[left][right] = true;
Edge* newEdge = new Edge(right);
newEdge->next = m_adjList[left]; //[color=FF0000]问题出在这两行,这样附的话[/color]
m_adjList[left] = newEdge; //[color=FF0000]是不是m_adjList[left]->next还是本身[/color]
}
}
struct Edge //这是对于边"Edge"的结构定义
{
int to;
Edge* next;
Edge(int _to) { to = _to; }
};
void addEdge(int left, int right) //在左顶点left和右顶点right之间添加边
{
if (!m_matrix[left][right]) //m_matrix[][]是检验是否已有边相连
{
m_matrix[left][right] = true;
Edge* newEdge = new Edge(right);
newEdge->next = m_adjList[left]; //[color=FF0000]问题出在这两行,这样附的话[/color]
m_adjList[left] = newEdge; //[color=FF0000]是不是m_adjList[left]->next还是本身[/color]
}
}