Class: LemonGraph::Graph::Arc

Inherits:
LemonGraph::GraphItem show all
Defined in:
ext/lemongraph/graph_arc.cc,
ext/lemongraph/lemongraph.cc

Overview

Arc of a LemonGraph::Graph, from a source Node to a target Node. Each Edge of a LemonGraph::Graph is composed of two arcs in opposite direction.

Instance Attribute Summary

Attributes inherited from LemonGraph::GraphItem

#graph, #id

Instance Method Summary collapse

Methods inherited from LemonGraph::GraphItem

#!=, #<=>, #==

Instance Method Details

#oppositeArc

Returns the arc corresponding to the same edge as self but in the opposite orientation.

Returns:



88
89
90
91
92
93
# File 'ext/lemongraph/graph_arc.cc', line 88

VALUE lemongraph_unarc_opposite(VALUE self)
{
	VALUE g = rb_iv_get(self, "@graph");
	lemon::ListGraph::Arc a = lemongraph_graph_rb2ref(g).oppositeArc(lemongraph_rbunarc2unarc(self));
	return lemongraph_make_unarc(a, g);
}

#sourceNode

Returns the source node of the arc.

Returns:



66
67
68
69
70
71
# File 'ext/lemongraph/graph_arc.cc', line 66

VALUE lemongraph_unarc_source(VALUE self)
{
	VALUE g = rb_iv_get(self, "@graph");
	lemon::ListGraph::Node n = lemongraph_graph_rb2ref(g).source(lemongraph_rbunarc2unarc(self));
	return lemongraph_make_unnode(n, g);
}

#targetNode

Returns the target node of the arc.

Returns:



77
78
79
80
81
82
# File 'ext/lemongraph/graph_arc.cc', line 77

VALUE lemongraph_unarc_target(VALUE self)
{
	VALUE g = rb_iv_get(self, "@graph");
	lemon::ListGraph::Node n = lemongraph_graph_rb2ref(g).target(lemongraph_rbunarc2unarc(self));
	return lemongraph_make_unnode(n, g);
}

#valid?Boolean

Test if the arc is valid, i.e. it is a real arc of the graph it belons to.

Returns:

  • (Boolean)


57
58
59
60
# File 'ext/lemongraph/graph_arc.cc', line 57

VALUE lemongraph_unarc_is_valid(VALUE self)
{
	return lemongraph_graph_rb2ref(rb_iv_get(self, "@graph")).valid(lemongraph_rbunarc2unarc(self)) ? Qtrue : Qfalse;
}