7.4.1. Accessing the RFG¶
You have to import the bauhaus.rfg module in order to use the RFG library (see Listing Importing the rfg part of bauhaus).
from bauhaus import rfg
You may also import the classes directly, so that you do not have to prefix them by rfg (see Listing Importing only the used classes from the rfg part of bauhaus).
from bauhaus import rfg
# import the classes you need
from bauhaus.rfg import Graph, View, Edge, Node
But in order to keep namespaces clean, we suggest you use from bauhaus import
rfg and qualify the classes with rfg.
The interface of the RFG features the following Python classes:
Graph |
The RFG graph is the summary of all facts about a system under analysis which can be modeled as a graph. A graph contains views which in turn contain nodes and edges. Attributes can be attached to the graph. A graph can be created, loaded, and saved. See Section Class Graph for more details. |
|---|---|
View |
A view is a subgraph of the graph. A view has a name and contains nodes and edges. Attributes can be attached to a view. A view can be created, and loaded and saved as GXL file. See Section Class View for more details. |
Node |
A node represents an entity of the analyzed system, either a source artefact or an element added during analysis. A node has a type. It can be contained in several views. A node can only be contained in one graph. Attributes can be attached to a node. See Section Class Node for more details. |
Edge |
An edge represents a relationship of entities of the analyzed system. An edge has a type. An edge can be contained in several views. An edge can only be contained in one graph. If it is contained in a view, its source and target node must also be contained in that view. Attributes can be attached to an edge. See Section Class Edge for more details. |
NodeSet |
A set of nodes. The nodes can be from different views and even different graphs. See Section Class NodeSet for more details. |
EdgeSet |
A set of edges. The edges can be from different views and even different graphs. See Section Class EdgeSet for more details. |
GraphAttribute |
A graph attribute can be attached to a graph. It has a name and an optional value. An attribute is typed. The type is one of “toggle”, “int”, “float”, and “string”. A graph attribute is graph specific. See Section Attribute Classes: GraphAttribute, ViewAttribute, NodeAttribute, and EdgeAttribute for more details. |
ViewAttribute |
A view attribute can be attached to a view. Other characteristics can be found in the explanation of graph attributes. See Section Attribute Classes: GraphAttribute, ViewAttribute, NodeAttribute, and EdgeAttribute for more details. |
NodeAttribute |
A node attribute can be attached to a node. Other characteristics can be found in the explanation of graph attributes. See Section Attribute Classes: GraphAttribute, ViewAttribute, NodeAttribute, and EdgeAttribute for more details. |
EdgeAttribute |
An edge attribute can be attached to an edge. Other characteristics can be found in the explanation of graph attributes. See Section Attribute Classes: GraphAttribute, ViewAttribute, NodeAttribute, and EdgeAttribute for more details. |
NodeType |
A node has a node type. A node type has a name. A node type can have a parent node type and derived node types. Node types are graph specific. See Section Type Classes: NodeType and EdgeType for more details. |
EdgeType |
An edge has an edge type. An edge type can have a parent node type and derived edge types. Edge types are graph specific. See Section Type Classes: NodeType and EdgeType for more details. |
GraphViewIter |
A graph view iterator enables iterating all views of a graph. It is mainly an auxiliary construct. See Section Classes GraphViewIter, GraphNodeIter, and GraphEdgeIter for more details. |
GraphNodeIter |
A graph node iterator enables iterating all nodes of a graph. It is mainly an auxiliary construct. See Section Classes GraphViewIter, GraphNodeIter, and GraphEdgeIter for more details. |
GraphEdgeIter |
A graph edge iterator enables iterating all edges of a graph. It is mainly an auxiliary construct. See Section Classes GraphViewIter, GraphNodeIter, and GraphEdgeIter for more details. |
ViewNodeIter |
A view node iterator enables iterating a view. It is mainly an auxiliary construct. See Section Classes ViewNodeIter and ViewEdgeIter for more details. |
ViewEdgeIter |
A view edge iterator enables iterating a view. It is mainly an auxiliary construct. See Section Classes ViewNodeIter and ViewEdgeIter for more details. |
NodeSetIter |
A node set iterator enables iterating a set of nodes. It is mainly an auxiliary construct. See Section Class NodeSetIter and EdgeSetIter for more details. |
EdgeSetIter |
An edge set iterator enables iterating a set of edges. It is mainly an auxiliary construct. See Section Class NodeSetIter and EdgeSetIter for more details. |
All functions of the bauhaus.rfg interface module are described solely from the perspective of a user of the RFG library. Some functions are able to handle more types of parameters but you are not intended to pass such parameters because they are just for internal implementation purposes of the library.
Caution
Make sure you do not rely on abilities that go beyond the interface shown here. If you are tempted to look into the actual implementation, you are advised that details may change without notice.