Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!apple!amdahl!fai!kurtl From: kurtl@fai.UUCP (Kurt Luoto) Newsgroups: comp.lang.c++ Subject: When to make member functions? Keywords: member functions, c++ Message-ID: <2506@fai.UUCP> Date: 28 Aug 89 16:41:07 GMT References: <1267@pc.ecn.purdue.edu> Reply-To: kurtl@fai.fai.com (Kurt Luoto) Organization: Fujitsu America, Inc Lines: 31 In article <1267@pc.ecn.purdue.edu> fai!amdahl!ames!mailrus!iuvax!pur-ee!pc.ecn.purdue.edu!filoj filoj@pc.ecn.purdue.edu (Jeffrey J Filo) writes: >I am doing thesis work with directed graphs for mechanical systems and >am interested in finding out if there are any class libraries available >for graph representation and manipulation. [ ... ] >Jeff Filo >filoj@pc.ecn.purdue.edu I don't know of any available libraries for graphs, but this article brings up some questions for me. I am currently writing a set of classes for graph representation. I am basing the implementation on that proposed in the article "A Versatile Data Structure For Edge-Oriented Graph Algorithms", Jurgen Ebert, CACM June 1987, Vol 30 No. 6, pp 513-519 My humble question for the wisdom of the net: When is it desirable to make a member function of a class? Obvious candidates are functions for traversing the nodes and edges of a graph. Less obvious are algorithms such as finding a minimum path between two vertices of a graph. In the latter case, the algorithm can be written in terms of the primitive functions provided by the graph class, and so is independent of the graph representation. Since there are so many things that you can do with a graph, it seems silly to encumber a simple graph class with all kinds of algorithmic functions. On the other hand, in other OOP languages you have no choice. E.g. in Eiffel, functions only exist as members of some class. What is appropriate for C++? (Honest, I am not trying to start any flame wars here.) ------------------- Kurt W. Luoto, neophyte net-poster. (If I knew what my mailer address was, I'd give it.)