Purpose:
|
Creates an instance of a graph edge for use in graph theory.
|
|
Derivation:
|
gedge : ACIS_OBJECT : -
|
|
Filename:
|
kern/kernel/kernutil/law/generic_graph.hxx
|
|
Description:
|
The concepts of vertex, edge, and graph have been implemented as the
C++ classes
gvertex,
gedge, and
generic_graph. (entity_gvertex is derived from
gvertex except that it contains a pointer to an entity in the model. Such an entity could be a cell or a face.) A
gvertex may be created with an optional
char *name. A
gedge may be created with two
gvertex pointers. An empty graph may be created and edges and vertices may be added to it by calling its
add_vertex and
add_edge methods. Once created, a graph may be interrogated, ordered, or subsetted in a number of ways.
|
|
|
The
C++ classes of
gvertex and
gedge are use counted in the same way that laws are use counted. That is to say that the are copied by calling the
add method and deleted by calling the
remove method.
|
|
|
To make a
gvertex or
gedge contain data, derive a class from the base classes of
gvertex and
gedge. Use a technique similar to the
entity_gvertex class which enables it to contain an entity pointer.
|
|
References:
|
KERN
|
gvertex
|
|
Data:
|
protected gvertex *v1;
|
|
First vertex of the edge.
|
|
|
protected gvertex *v2;
|
|
Second vertex of the edge.
|
|
|
public static int how_many;
|
|
Keeps track of how many
gvertexes have been created.
|
|
Constructor:
|
public: gedge::gedge
(
|
|
|
gvertex const* in_v1,
|
// vertex one
|
|
|
gvertex const* in_v2,
|
// vertex two
|
|
|
double in_weight
|
// weight of the edge
|
|
|
|
= 0.0
|
|
|
);
|
|
|
Creates an instance of
gedge between the two graph vertices supplied.
|
|
|
|
|
|
|
public: gedge::gedge
();
|
|
|
C++ allocation constructor requests memory for this object but does not populate it.
|
|
|
|
|
Destructor:
|
protected: virtual gedge::~gedge
();
|
|
|
Do not call this destructor directly. An instance of
gedge is deleted by calling the
remove method. This is necessary, because
gedge is use counted. This destructor will throw a
sys_error if it is called when its
use_count is not equal to zero.
|
|
|
|
Methods:
|
public: void gedge::add
() const;
|
|
|
The
C++ classes of
gvertex and
gedge are use counted in the same way that laws are use counted. That is to say that the are copied by calling the
add method and deleted by calling the
remove method.
|
|
|
|
|
|
|
public: void gedge::clear_kind
();
|
|
|
Sets the user-defined
kind array for this graph item to
NULL.
kind is actually a dynamic array. The
value argument specifies whether or not this graph edge is of the
kind number specified.
|
|
|
|
|
|
|
public: virtual ENTITY* gedge::get_entity
() const;
|
|
|
Returns
NULL.
|
|
|
|
|
|
|
public: int gedge::get_kind_size
() const;
|
|
|
Returns the number of entries in the
kind
array.
|
|
|
|
|
|
|
public: double gedge::get_weight
() const;
|
|
|
Gets the weight of the gedge.
|
|
|
|
|
|
|
public: logical gedge::is_kind
(
|
|
|
int which
|
// kind to test
|
|
|
) const;
|
|
|
Tests to see if this instance of the graph edge is of a particular (user-defined) kind.
|
|
|
|
|
|
|
public: logical gedge::is_loop
() const;
|
|
|
Returns
TRUE
if the first vertex is the same as the last vertex, thus
|
|
forming a loop.
|
|
|
|
|
|
|
public: logical gedge::operator!=
(
|
|
|
gedge const& in_edge
|
// test graph edge
|
|
|
) const;
|
|
|
Determines whether or not the supplied graph edge is not equal to this graph edge.
|
|
|
|
|
|
|
public: logical gedge::operator==
(
|
|
|
gedge const& in_edge
|
// test graph edge
|
|
|
) const;
|
|
|
Determines whether or not the supplied graph edge is equal to this graph edge.
|
|
|
|
|
|
|
public: void gedge::remove
();
|
|
|
The
C++ classes of
gvertex and
gedge are use counted in the same way that laws are use counted. That is to say that the are copied by calling the
add method and deleted by calling the
remove method.
|
|
|
|
|
|
|
public: void gedge::set_kind
(
|
|
|
int which,
|
// kind to use
|
|
|
logical value
|
// turn on or off
|
|
|
);
|
|
|
Assigns a user-defined
kind to this graph edge.
kind is actually a dynamic array. The
value argument specifies whether or not this graph edge is of the
kind number specified.
|
|
|
|
|
|
|
public: void gedge::set_weight
(
|
|
|
double in_weight
|
// weight
|
|
|
) const;;
|
|
|
Sets the weight of the
gedge.
|
|
|
|
|
|
|
public: gvertex const* gedge::vertex1
() const;
|
|
|
Returns the first vertex associated with this graph edge.
|
|
|
|
|
|
|
public: gvertex const* gedge::vertex2
() const;
|
|
|
Returns the second vertex associated with this graph edge.
|
|
Internal Use:
|
id, isa, same, type
|