Easy3D 2.5.3
Graph Class Reference

A Graph data structure with easy property management. More...

#include <easy3d/core/graph.h>

Inheritance diagram for Graph:
Model

Classes

class  BaseHandle
 
struct  Edge
 
class  EdgeAroundVertexCirculator
 
struct  EdgeConnectivity
 
class  EdgeContainer
 
class  EdgeIterator
 
class  EdgeProperty
 
class  ModelProperty
 
struct  Vertex
 
class  VertexAroundVertexCirculator
 
struct  VertexConnectivity
 
class  VertexContainer
 
class  VertexIterator
 
class  VertexProperty
 

Public Member Functions

Construct, destruct, assignment
 Graph ()
 default constructor
 
 ~Graph () override=default
 destructor
 
 Graph (const Graph &rhs)
 copy constructor: copies rhs to *this. performs a deep copy of all properties.
 
Graphoperator= (const Graph &rhs)
 assign rhs to *this. performs a deep copy of all properties.
 
Graphassign (const Graph &rhs)
 assign rhs to *this. does not copy custom properties.
 
Add new elements by hand
Vertex add_vertex (const vec3 &p)
 add a new vertex with position p
 
Edge add_edge (const Vertex &v1, const Vertex &v2)
 add a new edge connecting vertices v1 and v2
 
Memory Management
unsigned int vertices_size () const
 returns number of (deleted and valid) vertices in the graph
 
unsigned int edges_size () const
 returns number of (deleted and valid)edges in the graph
 
unsigned int n_vertices () const
 returns number of vertices in the graph
 
unsigned int n_edges () const
 returns number of edges in the graph
 
void clear ()
 Removes all vertices, edges, and properties (and resets garbage state). More...
 
void reserve (unsigned int nvertices, unsigned int nedges)
 reserve memory (mainly used in file readers)
 
void resize (unsigned int nv, unsigned int ne)
 
bool has_garbage () const
 are there deleted vertices or edges?
 
void collect_garbage ()
 remove deleted vertices/edges
 
bool is_deleted (Vertex v) const
 
bool is_deleted (Edge e) const
 
bool is_valid (Vertex v) const
 return whether vertex v is valid, i.e. the index is stores it within the array bounds.
 
bool is_valid (Edge e) const
 return whether edge e is valid, i.e. the index is stores it within the array bounds.
 
Low-level connectivity
bool is_isolated (Vertex v) const
 returns whether v is isolated, i.e., not incident to any edge
 
Vertex vertex (Edge e, unsigned int i) const
 returns the i'th vertex of edge e. i has to be 0 or 1.
 
Vertex source (Edge e) const
 returns the starting vertex of an edge, which is equal to vertex(e, 0).
 
Vertex target (Edge e) const
 returns the ending vertex of an edge, which is equal to vertex(e, 1).
 
Property handling
template<class T >
VertexProperty< T > add_vertex_property (const std::string &name, const T t=T())
 
template<class T >
EdgeProperty< T > add_edge_property (const std::string &name, const T t=T())
 
template<class T >
ModelProperty< T > add_model_property (const std::string &name, const T t=T())
 
template<class T >
VertexProperty< T > get_vertex_property (const std::string &name) const
 
template<class T >
EdgeProperty< T > get_edge_property (const std::string &name) const
 
template<class T >
ModelProperty< T > get_model_property (const std::string &name) const
 
template<class T >
VertexProperty< T > vertex_property (const std::string &name, const T t=T())
 
template<class T >
EdgeProperty< T > edge_property (const std::string &name, const T t=T())
 
template<class T >
ModelProperty< T > model_property (const std::string &name, const T t=T())
 
template<class T >
bool remove_vertex_property (VertexProperty< T > &p)
 remove the vertex property p
 
bool remove_vertex_property (const std::string &n)
 remove the vertex property named n
 
template<class T >
bool remove_edge_property (EdgeProperty< T > &p)
 remove the edge property p
 
bool remove_edge_property (const std::string &n)
 remove the edge property named n
 
template<class T >
bool remove_model_property (ModelProperty< T > &p)
 remove the model property p
 
bool remove_model_property (const std::string &n)
 remove the model property named n
 
bool rename_vertex_property (const std::string &old_name, const std::string &new_name)
 rename a vertex property given its name
 
bool rename_edge_property (const std::string &old_name, const std::string &new_name)
 rename an edge property given its name
 
bool rename_model_property (const std::string &old_name, const std::string &new_name)
 rename a model property given its name
 
const std::type_info & get_vertex_property_type (const std::string &name) const
 
const std::type_info & get_edge_property_type (const std::string &name) const
 
const std::type_info & get_model_property_type (const std::string &name) const
 
std::vector< std::string > vertex_properties () const
 returns the names of all vertex properties
 
std::vector< std::string > edge_properties () const
 returns the names of all edge properties
 
std::vector< std::string > model_properties () const
 returns the names of all model properties
 
void property_stats (std::ostream &output) const override
 prints the names of all properties to an output stream (e.g., std::cout) More...
 
Iterators & Circulators
VertexIterator vertices_begin () const
 returns start iterator for vertices
 
VertexIterator vertices_end () const
 returns end iterator for vertices
 
VertexContainer vertices () const
 returns vertex container for C++11 range-based for-loops
 
EdgeIterator edges_begin () const
 returns start iterator for edges
 
EdgeIterator edges_end () const
 returns end iterator for edges
 
EdgeContainer edges () const
 returns edge container for C++11 range-based for-loops
 
VertexAroundVertexCirculator vertices (Vertex v) const
 returns circulator for vertices around vertex v
 
EdgeAroundVertexCirculator edges (Vertex v) const
 returns circulator for edges around vertex v
 
Higher-level Topological Operations
unsigned int valence (Vertex v) const
 
Edge find_edge (Vertex a, Vertex b) const
 find the edge (a,b)
 
void delete_vertex (Vertex v)
 deletes the vertex v from the graph
 
void delete_edge (Edge e)
 deletes the edge e from the graph
 
- Public Member Functions inherited from Model
 Model (const std::string &name="unknown")
 Default constructor. The parameter name is optional, but it is useful for handling multiple models with the same viewer.
 
void set_name (const std::string &n)
 Sets/Changes the name of a model. Assigning a name to a model is optional, but it is useful for handling multiple models with the same viewer.
 
const std::string & name () const
 The name of a model.
 
const Box3bounding_box (bool recompute=false) const
 The bounding box of the model. More...
 
void invalidate_bounding_box ()
 Invalidates the bounding box of the model. So when bounding_box() is called, the bounding box will be re-computed. This function is typically called when the geometry of a model is changed.
 
virtual std::vector< vec3 > & points ()=0
 The vertices of the model. More...
 
virtual const std::vector< vec3 > & points () const =0
 The vertices of the model. More...
 
bool empty () const
 Tests if the model is empty.
 
virtual void property_stats (std::ostream &output) const
 Prints the names of all properties to an output stream (e.g., std::cout). More...
 
void set_renderer (Renderer *r)
 Sets the renderer of this model. More...
 
Rendererrenderer ()
 Gets the renderer of this model.
 
const Rendererrenderer () const
 Gets the constant renderer of this model.
 
void set_manipulator (Manipulator *manip)
 Attaches a manipulator to this model. More...
 
Manipulatormanipulator ()
 Gets the manipulator attached to this model.
 
const Manipulatormanipulator () const
 Gets the manipulator attached to this model.
 

Geometry-related Functions

const vec3position (Vertex v) const
 position of a vertex (read only)
 
vec3position (Vertex v)
 position of a vertex
 
const std::vector< vec3 > & points () const override
 vector of vertex positions (read only) More...
 
std::vector< vec3 > & points () override
 vector of vertex positions More...
 
float edge_length (Edge e) const
 compute the length of edge e.
 

Detailed Description

A Graph data structure with easy property management.

This implementation is inspired by Surface_mesh https://opensource.cit-ec.de/projects/surface_mesh

Examples
Tutorial_108_Graph, Tutorial_109_Graph_Connectivity, Tutorial_110_Graph_Property, and Tutorial_111_Graph_IO.

Member Function Documentation

◆ add_edge_property()

EdgeProperty< T > add_edge_property ( const std::string &  name,
const T  t = T() 
)
inline

add a edge property of type T with name name and default value t. fails if a property named name exists already, since the name has to be unique. in this case it returns an invalid property

Examples
Tutorial_110_Graph_Property.

◆ add_model_property()

ModelProperty< T > add_model_property ( const std::string &  name,
const T  t = T() 
)
inline

add a model property of type T with name name and default value t. fails if a property named name exists already, since the name has to be unique. in this case it returns an invalid property

◆ add_vertex_property()

VertexProperty< T > add_vertex_property ( const std::string &  name,
const T  t = T() 
)
inline

add a vertex property of type T with name name and default value t. fails if a property named name exists already, since the name has to be unique. in this case it returns an invalid property

Examples
Tutorial_110_Graph_Property.

◆ clear()

void clear ( )

Removes all vertices, edges, and properties (and resets garbage state).

After calling this method, the graph is the same as newly constructed.

◆ edge_property()

EdgeProperty< T > edge_property ( const std::string &  name,
const T  t = T() 
)
inline

if an edge property of type T with name name exists, it is returned. otherwise this property is added (with default value t)

◆ get_edge_property()

EdgeProperty< T > get_edge_property ( const std::string &  name) const
inline

get the edge property named name of type T. returns an invalid VertexProperty if the property does not exist or if the type does not match.

◆ get_edge_property_type()

const std::type_info & get_edge_property_type ( const std::string &  name) const
inline

get the type_info T of edge property name. returns an typeid(void) if the property does not exist or if the type does not match.

◆ get_model_property()

ModelProperty< T > get_model_property ( const std::string &  name) const
inline

get the model property named name of type T. returns an invalid ModelProperty if the property does not exist or if the type does not match.

◆ get_model_property_type()

const std::type_info & get_model_property_type ( const std::string &  name) const
inline

get the type_info T of model property name. returns an typeid(void) if the property does not exist or if the type does not match.

◆ get_vertex_property()

VertexProperty< T > get_vertex_property ( const std::string &  name) const
inline

get the vertex property named name of type T. returns an invalid VertexProperty if the property does not exist or if the type does not match.

◆ get_vertex_property_type()

const std::type_info & get_vertex_property_type ( const std::string &  name) const
inline

get the type_info T of vertex property name. returns an typeid(void) if the property does not exist or if the type does not match.

◆ is_deleted() [1/2]

bool is_deleted ( Edge  e) const
inline

returns whether edge e is deleted

See also
collect_garbage()

◆ is_deleted() [2/2]

bool is_deleted ( Vertex  v) const
inline

returns whether vertex v is deleted

See also
collect_garbage()

◆ model_property()

ModelProperty< T > model_property ( const std::string &  name,
const T  t = T() 
)
inline

if a model property of type T with name name exists, it is returned. otherwise this property is added (with default value t)

◆ points() [1/2]

const std::vector< vec3 > & points ( ) const
inlineoverridevirtual

vector of vertex positions (read only)

Implements Model.

◆ points() [2/2]

std::vector< vec3 > & points ( )
inlineoverridevirtual

vector of vertex positions

Implements Model.

◆ property_stats()

void property_stats ( std::ostream &  output) const
overridevirtual

prints the names of all properties to an output stream (e.g., std::cout)

Reimplemented from Model.

◆ resize()

void resize ( unsigned int  nv,
unsigned int  ne 
)
inline

Resize space for vertices, edges, and their currently associated properties. Note: ne is the number of edges.

◆ valence()

unsigned int valence ( Vertex  v) const

returns the valence (number of incident edges or neighboring vertices) of vertex v.

◆ vertex_property()

VertexProperty< T > vertex_property ( const std::string &  name,
const T  t = T() 
)
inline

if a vertex property of type T with name name exists, it is returned. otherwise this property is added (with default value t)

Examples
Tutorial_110_Graph_Property.

The documentation for this class was generated from the following files: