⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outputgraph.cc.svn-base

📁 Probabilistic graphical models in matlab.
💻 SVN-BASE
字号:
#include <OutputGraph.h>#include <Potential.h>#include <Node.h>#include <RandomVariable.h>using namespace std;using namespace boost;// Explicit Template Instantiations //typedef property< edge_index_t, unsigned int, DiscretePotential *> DiscretePairwiseEdgeProperty;typedef adjacency_list<vecS, vecS, undirectedS, MessageNode<DiscreteRandomVariable, boost::adjacency_list_traits<vecS, vecS, undirectedS>::vertex_descriptor> *, DiscretePairwiseEdgeProperty > DiscretePairwiseGraph;typedef subgraph <DiscretePairwiseGraph> SubDiscretePairwiseGraph;typedef property< edge_index_t, unsigned int > EdgeProperty;typedef adjacency_list<vecS, vecS, undirectedS, MessageNode<DiscreteRandomVariable, boost::adjacency_list_traits<vecS, vecS, undirectedS>::vertex_descriptor> *, EdgeProperty > DiscreteFactorGraph;typedef subgraph <DiscreteFactorGraph> SubDiscreteFactorGraph;typedef property< edge_index_t, unsigned int, ContinuousPotential *> NPEdgeProperty;typedef adjacency_list<vecS, vecS, undirectedS, GraphicalModelNode *, NPEdgeProperty > NPGraph;template void display_variables_graph < DiscretePairwiseGraph > (DiscretePairwiseGraph &);template void display_variables_graph < SubDiscretePairwiseGraph > ( SubDiscretePairwiseGraph &);template void display_variables_graph < DiscreteFactorGraph > (DiscreteFactorGraph &);template void display_variables_graph < NPGraph > (NPGraph &);template void display_subgraph < DiscretePairwiseGraph > (SubDiscretePairwiseGraph &);template void display_subgraph < DiscreteFactorGraph > (SubDiscreteFactorGraph &);template void display_subgraph < NPGraph > (subgraph < NPGraph> &);template void display_graph < DiscreteFactorGraph > (DiscreteFactorGraph &);template void display_graph < DiscretePairwiseGraph > (DiscretePairwiseGraph &);// End Template Instantiations //template <class Graph>void display_variables_graph(Graph &g){	typename graph_traits<Graph>::vertex_iterator u,u_end;		for (tie (u,u_end) = vertices(g); u != u_end; ++u)	{		g[*u]->get_random_variable()->display_probabilities();	}}template <class Graph>void display_subgraph(subgraph<Graph> & g){	typename graph_traits<Graph>::vertex_iterator u,u_end;	typename graph_traits<Graph>::adjacency_iterator v,v_end;		typename subgraph<Graph>::children_iterator s, s_end;			unsigned int a = 0;		for ( tie(s, s_end) = g.children(); s != s_end; ++s)	{		++a;				cout << "Subtree " << a << " (" << num_vertices(*s) << " vertices)" << endl;				for (tie (u,u_end) = vertices(*s); u != u_end; ++u)		{			cout << "Vertex " << s->local_to_global(*u)+1 << " is linked to: ";			for (tie (v, v_end ) = adjacent_vertices(*u, *s); v != v_end; ++v)			{				cout << s->local_to_global(*v)+1 << ", ";			}			cout << endl;		}		 	}				cout << "In total we had " << a << " trees created." << endl;}template <class Graph>void display_graph( Graph & g){	typename graph_traits<Graph>::vertex_iterator u,u_end;	typename graph_traits<Graph>::adjacency_iterator v,v_end;	for (tie (u,u_end) = vertices(g); u != u_end; ++u)	{			cout << "Vertex " << *u +1 << " is linked to: ";					for (tie (v, v_end ) = adjacent_vertices(*u, g); v != v_end; ++v)			{				cout << *v +1<< ", ";			}			cout << endl;		}		}template <class Graph>void display_graph_old (Graph & g){	typename graph_traits<Graph>::vertex_iterator u, u_end;	typename graph_traits<Graph>::adjacency_iterator v, v_end;		typename property_map <Graph, vertex_index_t>::type vertex_index_map = get(vertex_index, g);		cout << "Graph contains " << num_vertices(g) << " vertices and " << num_edges(g) << " edges" << endl;		for (tie (u, u_end) = vertices (g); u != u_end; ++u)	{		cout << "Vertex " << get(vertex_index_map,*u)+1 << " is linked to: ";		for (tie (v, v_end ) = adjacent_vertices(*u, g); v != v_end; ++v)		{			cout << get(vertex_index_map,*v)+1 << ", ";		}		cout << endl;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -