Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.programming > #1282

Re: Attempting to implement "weird" kind of graph

From "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Newsgroups comp.lang.c++, comp.programming
References <7b9a51ce-483a-4b45-8024-4eb070a7c894@b4g2000pbi.googlegroups.com>
Subject Re: Attempting to implement "weird" kind of graph
Date 2012-02-05 11:53 +0000
Message-ID <gd6dneoDN7eb8LPSnZ2dnUVZ8gOdnZ2d@bt.com> (permalink)

Cross-posted to 2 groups.

Show all headers | View raw


mike3 wrote:

> I've been attempting to write a program in C++ that implements the
> “weird kind of graph”

Not too hopeful that this'll help, but here goes anyway...

I get the impression that you're all snarled-up in the mechanics of C++ 
programming, rather than thinking about the objects/roles/operations that are 
appropriate to your target domain.  If you start talking about "constructors", 
"destructors", "iterators", before you've really decided what your objects are 
going to /do/ then I think that's a bad sign -- you are thinking about how you 
are going to represent something in a concrete (and pretty lame) language, C++, 
before you've thought about /what/ you want to represent.

I haven't really followed the ins and outs of your discussion on this thread, 
and in the original one of c.l.c++, but it seems to me that you have:

    A Graph (aka Web)

    which is made of Strings

    each of which is made of a sequence of Nodes.

    Strings connect to other Strings at a Node.

    Each node is part of exactly one String and has a well-defined position 
(index) on that String.

    Each String has exactly two endpoints which are nodes on other Strings.

Some questions:

    Can Strings be of zero length (ie no "internal" nodes, just the endpoints 
which are on other Strings)?

    Do you need to associate data with the fact that one string terminates in 
another one?

    Do you need to associate data with the fact that two "internal" nodes are 
adjacent on their owining String?

    If you delete a node which is the endpoint of a String, what happens to 
that String.

    More generally, do you need to modify the structure once it has been 
created ?

    Do you need "fast" graph-theoretic operations (mu guess would be no).

    And so on and so on...

Regardless of the specific answers to the questions, there is a 
straight-forward data-structure here (or if may become complicated if you have 
stringent performance constraints).  So my ultimate question is "why not 
program it like that ?"  No "node ID's", no "node indexes" (unless your domain 
needs them -- which I doubt).  Represent Graphs by instances of class Graph, 
Strings by instances of class String (in some non-std namespace ;-), and Nodes 
by instances of class Node...

    -- chris

P.S.  My "pretty lame" comment is not intended as a troll for the readers on 
c.l.c++ -- which I have only just noticed that this is cross-posted to -- but 
is the sincere, and relevant, opionon of a reader of the language-agnostic 
group comp.programming. 

Back to comp.programming | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Attempting to implement "weird" kind of graph mike3 <mike4ty4@yahoo.com> - 2012-01-24 18:21 -0800
  Re: Attempting to implement "weird" kind of graph mike3 <mike4ty4@yahoo.com> - 2012-01-31 01:38 -0800
    Re: Attempting to implement "weird" kind of graph Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-31 12:47 +0000
      Re: Attempting to implement "weird" kind of graph mike3 <mike4ty4@yahoo.com> - 2012-01-31 13:46 -0800
  Re: Attempting to implement "weird" kind of graph "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-02-05 11:53 +0000
    Re: Attempting to implement "weird" kind of graph mike3 <mike4ty4@yahoo.com> - 2012-02-07 15:52 -0800

csiph-web