1
//------------------------------------------------------------------------------
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1996, Vrije Universiteit Amsterdam.
5
// Author: Frank Dehne (frank@cs.vu.nl).
7
// TCM is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// TCM is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with TCM; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
//-----------------------------------------------------------------------------
27
/// Graph edge class, base class of all edges. An edge connects two subjects.
28
class Edge: public Subject {
29
/*@Doc: {\large {\bf scope:} diagram} */
32
Edge(Graph *g, Subject *n1, Subject *n2);
37
/// edge connects subject1 and subject2.
38
Subject *GetSubject1() const {return subject1;}
40
/// when edge is directed then subject1 is 'from' and subject2 'to'.
41
Subject *GetSubject2() const {return subject2;}
44
void SetSubject1(Subject *n) {subject1 = n;}
46
void SetSubject2(Subject *n) {subject2 = n;}
49
bool IsDirected() const {return directed;}
51
/// is edge part of the graph?
54
/// yes of course it is
55
bool IsEdge() const {return True;}
57
/// is subject one of the two subjects that edge connects?
58
bool PartOf(Subject *subject) const {
59
return (subject == subject1) || (subject == subject2);}
62
void SetSubjects(Subject *n1, Subject *n2, bool d = 0)
63
{subject1 = n1; subject2 = n2; directed = d;}
65
/// write attributes to file.
66
void WriteMembers(OutputFile *f);
68
/// read and check attributes from file.
69
bool ReadMembers(InputFile *f, double format);
71
/// set and check references to subjects after reading.
72
bool SetReferences(AssocList *);
74
/// check whether subject references exist.
75
bool CheckReferences();
78
void SetDirected(bool b) {directed=b;}
86
/// is the edge directed?
89
/// part of SetReference.
90
bool SetSubjectReference(AssocList *al, Subject **subject, int which);