Changeset fa8ca4
- Timestamp:
- 06/04/12 17:36:59 (12 months ago)
- Branches:
- master
- Children:
- 2ca0c3
- Parents:
- e43e4e
- git-author:
- Tiago de Paula Peixoto <tiago@…> (06/04/12 16:27:03)
- git-committer:
- Tiago de Paula Peixoto <tiago@…> (06/04/12 17:36:59)
- Location:
- src
- Files:
-
- 1 added
- 3 edited
-
graph/topology/Makefile.am (modified) (1 diff)
-
graph/topology/graph_bipartite.cc (added)
-
graph/topology/graph_topology.cc (modified) (2 diffs)
-
graph_tool/topology/__init__.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/graph/topology/Makefile.am
r4453f7 rfa8ca4 17 17 libgraph_tool_topology_la_SOURCES = \ 18 18 graph_all_distances.cc \ 19 graph_bipartite.cc \ 19 20 graph_components.cc \ 20 21 graph_distance.cc \ -
src/graph/topology/graph_topology.cc
r4453f7 rfa8ca4 39 39 size_t n_max, size_t seed); 40 40 double reciprocity(GraphInterface& gi); 41 bool is_bipartite(GraphInterface& gi, boost::any part_map); 41 42 42 43 void export_components(); … … 60 61 def("is_planar", &is_planar); 61 62 def("reciprocity", &reciprocity); 63 def("is_bipartite", &is_bipartite); 62 64 export_components(); 63 65 export_similarity(); -
src/graph_tool/topology/__init__.py
r01fd54 rfa8ca4 45 45 label_biconnected_components 46 46 label_largest_component 47 is_bipartite 47 48 is_planar 48 49 edge_reciprocity … … 67 68 "transitive_closure", "label_components", "label_largest_component", 68 69 "label_biconnected_components", "shortest_distance", "shortest_path", 69 "pseudo_diameter", "is_ planar", "similarity", "edge_reciprocity"]70 "pseudo_diameter", "is_bipartite", "is_planar", "similarity", "edge_reciprocity"] 70 71 71 72 … … 1007 1008 1008 1009 1010 def is_bipartite(g, partition=False): 1011 """ 1012 Test if the graph is bipartite. 1013 1014 Parameters 1015 ---------- 1016 g : :class:`~graph_tool.Graph` 1017 Graph to be used. 1018 partition : bool (optional, default: ``False``) 1019 If ``True``, return the two partitions in case the graph is bipartite. 1020 1021 Returns 1022 ------- 1023 is_bipartite : bool 1024 Whether or not the graph is bipartite. 1025 partition : :class:`~graph_tool.PropertyMap` (only if `partition=True`) 1026 A vertex property map with the graph partitioning (or `None`) if the 1027 graph is not bipartite. 1028 1029 Notes 1030 ----- 1031 1032 An undirected graph is bipartite if one can partition its set of vertices 1033 into two sets, such that all edges go from one set to the other. 1034 1035 This algorithm runs in :math:`O(V + E)` time. 1036 1037 Examples 1038 -------- 1039 >>> g = gt.lattice([10, 10]) 1040 >>> is_bi, part = gt.is_bipartite(g, partition=True) 1041 >>> print(is_bi) 1042 True 1043 >>> gt.graph_draw(g, vertex_color=part, output_size=(300, 300), output="bipartite.pdf") 1044 <...> 1045 1046 .. figure:: bipartite.* 1047 :align: center 1048 1049 Bipartition of a 2D lattice. 1050 1051 References 1052 ---------- 1053 .. [boost-bipartite] http://www.boost.org/libs/graph/doc/is_bipartite.html 1054 """ 1055 1056 if partition: 1057 part = g.new_vertex_property("bool") 1058 else: 1059 part = None 1060 g = GraphView(g, directed=False) 1061 is_bi = libgraph_tool_topology.is_bipartite(g._Graph__graph, 1062 _prop("v", g, part)) 1063 if partition: 1064 return is_bi, part 1065 else: 1066 return is_bi 1067 1068 1009 1069 def is_planar(g, embedding=False, kuratowski=False): 1010 1070 """
Note: See TracChangeset
for help on using the changeset viewer.


