views:

75

answers:

3

How would I usually represent this business logic in a graph?

A is true if
 B is true or
 C is true

C is true if
 D is true and
 E is true and
 F is true

X is true if
 Y is true and
 C is not true 

Is it a directed acyclic graph? How do I represent the 'and'/'or' logic in the graph, in graph terminology?

(I am looking for the correct graph terminology, so I can focus my reading.)

+3  A: 
     (D)  (E)  (F)
      |    |    |
       \   |   /
         [AND]
          |
(B)      (C)
 |       |
  \     /
   [OR]
    |
   (A)

How about a graph with some nodes representing boolean variables and others boolean operations?

This is directed acyclic graph.

NOTE: I am not sure if this is very helpful.Expecting comments. :)

TheMachineCharmer
So would there be three 'colors' of vertices in this graph? Say: AND: Red, OR: Blue, boolean variable: Green.
Nick Miller
Yes. You can color them.
TheMachineCharmer
+1, though your upside-down graph frightens and confuses me.
John Kugelman
Is there a way to get rid of the [AND] and [OR] nodes and express that info in the other nodes? It seems weird that every node (except the leaf nodes) in the graph would be connected first to an [AND] or [OR] node, and it seems weird to have fundamentally different types of nodes. Is it?
Nick Miller
:) +1 John I wanted it to resemble flow of mathematical reasoning. You start with some parameters(D,E,F), add few more(B) on the way and then reach to conclusion(A) in the end.
TheMachineCharmer
@Nick I don't find having different types of nodes that weird though as you said its better if they all are of same time.
TheMachineCharmer
@Nick Miller: Sometimes, an arc through the connecting lines near the "descendant node" (so in this case, C) is used to symbolize an AND relationship. I suspect a more generalized method would be to draw an arc through, then note how many are needed to be "true" for the descendant to be "true". I don't know how common this practice is, though.
Vatine
+1  A: 

What about using Karnaugh maps? To me they feel a natural form to represent your data..

Eddy
+1  A: 

Ok, so you might want to look at the Specification pattern for this.

But it sounds like you are seriously overcomplicating things... you just need a composite data type. Call it whatever you like, so long as it works.