Beispiel #1
0
int main()
{
	while(init())
	{
		if(has_euler_path() == 0)
		{
			printf("Round trip does not exist.\n");
			continue;
		}
		memset(visited, 0, sizeof(visited));
		top = 0;
		find_euler(st);
		while(top > 1) printf("%d ", stack[top--]);
		printf("%d\n", stack[1]);
	}
	return 0;
}
Beispiel #2
0
inline bool euler_path(const Graph& g,
                       typename boost::graph_traits<Graph>::vertex_descriptor s,
                       UnaryFunction f,
                       boost::undirected_tag)
{
    BOOST_CONCEPT_ASSERT(( boost::VertexAndEdgeListGraphConcept<Graph> ));

    if (!has_euler_path(g, s))
        return false;

    typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_desc;
    std::map<std::pair<vertex_desc, vertex_desc>, int> matrix;

    std::size_t path_size = 0;
    visit(g, matrix, s, f, path_size);

    return path_size == num_edges(g) + 1;
}