\abstract{
This paper discusses a two stage algorithm designed to greatly
reduce the number of Area compare operations required to determine which zones are `available' in an Euler
diagram.

This algorithm will aid in the quick resolution of complex drawn 
Euler diagrams where the available zones on the diagram must be known.

An Euler diagram of $N$ contours has a possible $2^N$ zones.
A `brute force' search for available zones (determining for availability of all possible $2^N$
zones) involves $N.2^N$ Area Compare operations.

The first stage of the algorithm identifies $M$ number of unique groups of contours that are isolated
w.r.t. zone production. Thus each identified group of $nn$ contours
has a maximum of $2^{nn}$ zones.  This reduces the exponential overhead of the $N.2^N$ order. 
In fact we reduce the number of stages to search from a $N.2^N$ order 
to approximately $N^2 + M.2^{nn}$.

The next stage reduces the number of searches required within the isolated
groups, (thus reducing the $M.2^{nn}$ terms) by traverssing a graph 
of the relationships between the contours.
}
\section{Introduction : Euler Diagram and Zones Available for use}

Euler diagrams consist of closed curves in the plane which are used to represent sets.
The spaitial relationship between the curves defines the set theoretic relationships.
\begin{itemize}
\item Intersection - if the curves overlap
\item Sub-set      - if a curve is enclosed by another
\item disjoint     - if the curves are separate
\end{itemize}

\paragraph{Defining a Zone as two sets of Contours}
%A zone is defined as a region of the plane where a set of curves will enclose it
%and another set is disjoint from it.
A zone can be defined by the sets that enclose the region on the plane defining the zone (the $A$ set), and the sets
that are disjoint from it (the $B$ sets).
\paragraph{Difference between a Venn and an Euler Diagram}
A Venn diagram is an Euler diagram where all possible zones are present.
Thus if a Venn diagram has $N$ countours it will have $2^N$
zones.
%
An Euler diagram, does not have to  make all possible zones available.
Thus we can make certain combinations of contours unavailable
by drawing the diagrams. Or in other words we can deliberately restrict
not only combinations of contours but also the number of available zones.
%
In Constraint Diagram and PLD's Euler diagrams are used
and objects are placed upon the available zones.
%
\paragraph{Importance of determining available zones}
When performing  logical reasoning on euler diagrams,
it is important to note which available zones do not have objects associated with them in order to flag the unhandled cases in the diagram.
These could represent cases where the user has left them undefined, or considers them to
be a general case. Either way they need to be flagged as an ommission error or
collected. In order to do this a method of finding all available zones is necessary.
%
Also note that in a complicated diagram, a zone may, at first glance, appear available, but could be covered-up or obscured by
an enclosing contour.

%The sizes or shapes of the curves are not important, the significance of the diagram is in how they overlap.
%The spatial relationships between the regions bounded by each curve (overlap, containment or neither) corresponds to set-theoretic relationships (intersection, subset and disjointness).
%
%Each Euler curve divides the plane into two regions or "zones": the interior, which symbolically represents the elements of the set, and the exterior, which represents all elements which are not members of the set. 
%Curves which do not intersect represent disjoint sets. Two curves which intersect represent sets that have common elements; the zone inside both curves represents the set of elements common to both sets (the intersection of the sets). A curve which is contained completely within another represents a subset of it.
%
%Venn diagrams are a more restrictive form of Euler diagrams. 
%A Venn diagram must contain all the possible zones of overlap between its curves, representing all combinations of inclusion/exclusion of its constituent sets, but in an Euler diagram some zones might be missing. 
%Therefore there is only one Venn diagram representing the relationships between n sets, with 2n zones, but there may be many Euler diagrams.
%(An example is given below in the History section; in the top-right illustration the O and I diagrams are merely rotated; Venn stated that this difficulty in part led him to develop his diagrams).

\par

\paragraph{definition of `available'}

For a zone to be available for use it must

\begin{itemize}
\item {Exist} meaning that the contours making up the zone must intersect.
\item {Not be Obscured} The intersection must not be covered by other zones.
\end{itemize}


\par


Each zone can be defined by the contours that intersect to define it and the remaining 
contours in the diagram.
Thus for a diagram $ D $ consisting of a set of zones $ Z $ where the  zones in the diagram 
$ Z_{n} $
 are  defined as a sets of intersection contours $ A_{n} $, and exclusion sets 
$ B_{n} $.


\begin{figure}[h]
 \centering
 \includegraphics[width=400pt,bb=0 0 315 217,keepaspectratio=true]{fzd/exampleareasubtraction1.jpg}
 % exampleareasubtraction1.jpg: 438x301 pixel, 100dpi, 11.13x7.65 cm, bb=0 0 315 217
 \caption{Simple Euler Diagram}
 \label{fig:ex1}
\end{figure}

\subsection{Testing a Zone for Existance}

The Java Area, Shape and Polygon classes, provide functions to
intersect, subtract and `exclusive or' Areas on the plane. They are thus
very useful in testing objects drawn under a Java environment.
%
To determine if a zone exists we can apply the intersection
functions to all the $A_{N}$ contours. If any $|Area|$ remains
the zone exists. To check that the zone is available, we must
also ensure that it is not covered over/obscured by a contour in the $ B_{N}$ set.

\subsection{Testing for Obscuration}
Firstly apply intersection to all the $A_{n}$ contours in the Zone.
We are then left with the area of intersection only.
%
From this we can subtract all the areas from the $B_{n}$ contours.
If the zone was obscured, or covered up the Area object will register that it has no area on the plane.
%
In other words, a zone obscured by other contours is one that forms the area of intersection
of the set $ A_{n} $ and then having all the areas from set $ B_{n} $ subtracted from it
no surface area left.
%
Firstly let us define the meaning of availability in concrete area terms by means of an example diagram.
In figure \ref{fig:ex1}, there is an Euler diagram with the following zones available.


\par
\vspace{0.3cm}
\begin{tabular}{||l|l|c|c||} \hline \hline
  {\em Included set $A_{n}$ } & {\em Excluded $set B_{n}$ } &  & {\em Available}      \\ \hline
  \{ \}           &  \{ D C B A \}    & 1    &  Y      \\ \hline
  \{ A \}         &  \{ D C B \}      & 2    &  Y            \\ \hline
  \{ B \}         &  \{ D C A \}      & 3    &  Y             \\ \hline
  \{ B A\}         &  \{ D C  \}      & 4    &  Y            \\ \hline
  \{ C \}         &  \{ D B A \}      & 5    &  N           \\ \hline
  \{ C A  \}         &  \{ D B \}      & 6   &  N            \\ \hline
  \{ C B  \}         &  \{ D A \}      & 7   &  N     \\ \hline
  \{ C B A \}         &  \{ D  \}      & 8   &  N             \\ \hline
  \{ D \}         &  \{ C B A  \}      & 9  &  Y             \\ \hline
  \{ D A \}         &  \{ C B \}      & 10   &  N            \\ \hline
  \{  D B \}         &  \{  C A \}      & 11    &  Y             \\ \hline
  \{ D B A\}         &  \{  C  \}      & 12    &  N            \\ \hline
  \{ D C \}         &  \{  B A \}      & 13    &  Y           \\ \hline
  \{ D C A  \}         &  \{  B \}      & 14   &  N            \\ \hline
  \{ D C B  \}         &  \{  A \}      & 15   &  Y     \\ \hline
  \{  D C B A \}         &  \{   \}      & 16   &  N             \\ \hline
 \hline
\end{tabular}
\vspace{0.3cm}

 Note $B \cap C$ and $ C $ are not available in this diagram because it is impossible to place objects on them.
 Objects could be placed on $ B \cap C \cap D $ and $ B \cap D $ however.
% 
%  \begin{figure}
%  \vskip 4.2cm
%  \special{psfile=fzd/exampleareasubtraction1.eps hoffset=0 voffset=-10 hscale=60 vscale=60}\caption[Area Intersection]{
%  Simple Euler Diagram
%  \label{fig:ex1}}
%  \end{figure}

 Examining the intersection $ A \cap B $ the corresponding Area is shown in red 
 in figure \ref{fig:ex2}.

\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 315 217,keepaspectratio=true]{fzd/exampleareasubtraction2.jpg}
 % exampleareasubtraction2.jpg: 438x301 pixel, 100dpi, 11.13x7.65 cm, bb=0 0 315 217
 \caption{Area representation of intersection between A and B}
 \label{fig:ex2}
\end{figure}

%  \begin{figure}
%  \vskip 4.2cm
%  \special{psfile=fzd/exampleareasubtraction2.eps hoffset=0 voffset=-10 hscale=60 vscale=60}\caption[Area Intersection]{
%  Area representation of intersection between set A and B
%  \label{fig:ex2}}
%  \end{figure}

 The area to be subtracted is shown in blue in figure \ref{fig:ex3}.
 Note that here the intersection exists
 and is not obscured by the areas made up from the other contours. 
 It is therefore available.
 It can be seen that the zone $ B \cap C $ is not available in the 
 diagram because it is obscured by the
 areas comprised of the other contours  $ C \cup D $ 
 (in fact in this diagram  only $ D $ is required to prove obscuration
 because $ C \subset D $ ).
\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 315 217,keepaspectratio=true]{fzd/exampleareasubtraction3.jpg}
 % exampleareasubtraction3.jpg: 438x301 pixel, 100dpi, 11.13x7.65 cm, bb=0 0 315 217
 \caption{Area representation of exclusion zone to be subtracted}
 \label{fig:ex3}
\end{figure}
% 
% \begin{figure}
% \vskip 4cm
% \special{psfile=fzd/exampleareasubtraction3.eps hoffset=0 voffset=-10 hscale=60 vscale=60}\caption[Area Intersection]{
% Area representation of exclusion Zone to be subtracted
% \label{fig:ex3}}
% \end{figure}

%\begin{picture}(200,200)(10,10)
%\put(20,0){\circle{20}}
%\end{picture}


%\clearpage 

\subsection{Formal expression of Area Operations}

This section deals with operations on  the concrete diagrams using Areas.
An intersection for instance therefore represents an intersection of the Areas
denoted by the contours.


\equation 
\label{available5}
{AreaIntersection}_{n} = \; \stackrel{\bigcap a }{a \in A_{n} \wedge a \not\in B_{n}}
\endequation

Note this implies contours in $B_{n}$ could intersect with the zone formed by $A_{n}$, but where all
contours in $B_{n}$ represent those excluded from the zone under scrutinty.

\par
The $AreaIntersection_{n}$ may form a zonal region,% \cite{cried}, 
but for the purposes of this investigation, 
may be interpreted as a boolean variable.
There is either surface area or not. The zone exists or does not.

\equation 
\label{available6}
{AreaExclusion}_{n} =  \; \stackrel{\bigcup b }{b \not\in A_{n} \wedge b \in B_{n} }
\endequation



%\begin{eqnarray}
\equation 
\label{available7}
\begin{array}[t]{c}
  {RemainingIntersection}_{n} =  \\
   {AreaIntersection}_{n} -  {AreaExclusion}_{n} 
\end{array}
\endequation
%\end{eqnarray}
Note the subtraction here is again, an Area operation.
The remaining intersection could be one or more visible zones on the diagram, 
but as long as there is some surface area
left, then the zone has not been obscured.
It can thus be used as a boolean variable. If $surface\_area > 0 $ exists in the ${RemainingIntersection}_{n}$ then 
the expression is true.


%\clearpage 

\subsection{Testing for zone Availability}

Firstly that the intersection exists in the concrete diagram.
\equation 
\label{available1}
%Z_{n} = (A_{n},B_{n}) \Rightarrow  \forall \; A_{n} \; \mid \; a \cap A_{n} 
Z_{n} = (A_{n},B_{n}) \; \Rightarrow \; AreaIntersection_{n}
\endequation

If the above implication is true we can go on to test for obscuration.
.
\equation
\label{available2}
Z_{n} = (A_{n},B_{n}) \Rightarrow   \; RemainingIntersection_{n} 
\endequation

And finally the sets A and B added together must be equal to the set of all countours in
diagram D, i.e. all contours must be represented in $A_{n}$ and $B_{n}$.

\equation
\label{available3}
 B_{n} \cup A_{n} = D 
\endequation

A zone is thus considered {\em available} if the above criteria (i.e. equations  \ref{available1},\ref{available2},\ref{available3} )  are true.

\subsection {Algorthms for finding Available Zones} 

One could take all possible combinations of contours and check each case.
For all combinations of contours, examine to find out if the intersection exists, and then if it does, examine all
the excluded contours and ensure that they do not obscure the intersection. If both conditions are trus the zone is 'available'.
\par
Checking all possible combinations is henceforth referred to as the 'Brute force method'.
\par
The brute force method is  simple, and
would be practical for small numbers of contours. However as constraint/spider
diagrams become used in practise larger numbers of contours and very large diagrams will become common.
\par
For instance were a diagram to contain 32 contours, to brute forcecheck for the existance of all contours would take 
all possible combinations of 32 objects. This corresponds to a binary count and thus $ 2^{32} $ possible zones to check for.
\par
A diagram with 32 contours would contain a potential of over 4 billion zones.
\par
Multiply that by the on average 16 operations ( area intersection compares ) that must be carried 
out for each zone, added to an average of 16 obscuration comparisons,  
and an astronomical number of area comparisons would be required ($ 32.2^{32} $). 
%A similar problem existed with computational frequency analysis
%in the mid 1960's where the algorithmically more efficient FFT \cite{fft} became the industry standard
%as opposed to the DFT.
\par
In general then the brute force zone search, with obscuration testing, takes 
\equation
2^{N}.2.\frac{N}{2} 
\endequation

or 

\equation
\label{bruteforce}
N.2^{N} 
\endequation

\par
 
 This author therefore sees an efficient algorithm for determining available zones as a necessity 
for a practical euler/spider diagram analyser.

\par
The algorithm described in this paper works on the principle of examining the 
contours for two types of relationships.
This information is then used to create directed graphs, which are then traversed. From the spanning trees, 
most of the non available zones are eliminated early on. For zones which may be available, two tests are required.
The first that they actually exist in the concrete diagram, and secondly that they are not obscured by
 combinations of other contours.
The initial searches form two cross products of the contours (see \ref{detpe} )
 performing $2.N^2$ area operations.

After these initial area operations subsets of the contours can be defined (pure intersection chains)
by traversing the pure intersection relationships. The pure intersection chains
are subsets of the contours in the diagram.
These subsets of the contours are denoted as the set $G$.
In searching for the availability of zones, area operations only need be applied 
within each set $G$.
By only having to search within subsets of the contours effeciency of the algorithm is improved.
For the brute force algorithm, $ G \equiv N $.
 
For each potential zone identified, it  must be checked against $G\#$ other contours
where $ G  \subseteq N$
 for proof of concrete existence and 
for obscuration. The set $ G $ is divided into two, those included in the prospective zone $I$
 and those outside and 
used to check for obscuration  $ O $ . Note $ O + I \leq N $ because $ G \subseteq N $.
Thus for this algorithm, where $ Z\# $ is the number of potential zones as identified by tree spanning

\equation
\label{seteq}
2.N^{2} + Z\#.G
\endequation

\equation
\label{incobs}
2.N^{2} + Z\#.(O + I)
\endequation

Thus for a $ Venn N $ diagram this algorithm is less efficient by $ 2.N^{2} $ 
i.e. for a Venn N diagram  $Z\# = N^{2}$

\equation
%\label{fzditer1}
2.N^{2} + 2^{N}.2.\frac{N}{2}
\endequation

\equation
%\label{fzditer1}
2.N^{2} + 2^{N+1}
\endequation


 But for any diagram less
complicated than Venn N, where $ Z\# $ 
is small in comparison with $2^{N}$ the algorithm becomes far more efficient.

Examples of complexity savings are shown in section \ref{complexity}.


\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 642 482,keepaspectratio=true]{fzd/piee.jpg}
 % piee.jpg: 891x669 pixel, 100dpi, 22.63x16.99 cm, bb=0 0 642 482
 \caption{A Pure Intersection and an Enclosure}
 \label{fig:piee}
\end{figure}

% \begin{figure}
% \vskip 6cm
% \special{psfile=fzd/piee.ps hoffset=0 voffset=-10 hscale=40 vscale=40}\caption[Pure Intersection Zone Capture Method]{
% A Pure Intersection  and an Enclosure
% \label{fig:piee}}
% \end{figure}
\subsection { Relationships between Contours }

The algorithm for fast finding of available zones depends upon defining three new relationships between contours.
 
\begin{itemize}
\item {Pure Intersection}
\item {Enclosure}
\item {Belonging to a Pure Intersection Chain}
\end{itemize}

\subsection { Pure Intersection }

A pair of contours are said to have 'pure intersection' if the contours overlap.

\subsection{Enclosure}

A countour is said to be enclosed if it fits completely within another contour.

\subsection { Pure Intersection Chains }

\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 642 482]{fzd/pic.jpg}
 % pic.jpg: 891x669 pixel, 100dpi, 22.63x16.99 cm, bb=0 0 642 482
 \caption{Pure Intersection Zone Chain}
 \label{fig:pic}
\end{figure}
% 
% \begin{figure}
% \vskip 6cm
% \special{psfile=fzd/pic.ps hoffset=0 voffset=0 hscale=40 vscale=40}\caption[Pure Intersection Zone Capture Method]{
% Pure Intersection Zone Chain
% \label{fig:pic}}
% \end{figure}

Pairs of contours may belong to the same pure intersection chain.
Pure Intersection chains are a chain of contours that can all 
be linked together by pure intersection relationships ( see figure \ref{fig:pic} ).
Contours in the pure intersection chain may enclose other members
in the same chain, but not the contour that they are purely intersected with (see figure \ref{fig:picwaie}).
\par
Pure intersections relationships for the diagram in figure \ref{fig:pic} are :-
$$
\begin{array}{lcl}
A & \stackrel{pi}\longrightarrow & B    \\
B & \stackrel{pi}\longrightarrow & A    \\
B & \stackrel{pi}\longrightarrow & C    \\
C & \stackrel{pi}\longrightarrow & B    \\
D & \stackrel{pi}\longrightarrow & C    \\
C & \stackrel{pi}\longrightarrow & D    \\
\end{array}
$$

\par
Relationships for the diagram in figure \ref{fig:picwaie} include one enclosure.

$$
\begin{array}{lcl}
A & \stackrel{pi}\longrightarrow & B    \\
B & \stackrel{pi}\longrightarrow & A    \\
B & \stackrel{pi}\longrightarrow & C    \\
C & \stackrel{pi}\longrightarrow & B    \\
D & \stackrel{pi}\longrightarrow & C    \\
C & \stackrel{pi}\longrightarrow & D    \\
E & \stackrel{pi}\longrightarrow & C    \\
C & \stackrel{pi}\longrightarrow & E    \\
\\
E & \stackrel{enc}\longrightarrow & D    \\
\end{array}
$$

Because {\em A,B,C,D} all share pure intersection connections they all belong to the same pure intersection chain.

NB: Three or more linked pure intersections contitute a 'pure intersection chain'.

\subsection { Determining the Pure Intersection and Enclosure Relationships }
\label{detpe}
By applying java Area searches for enclosure and intersection on each
contour against all others a collection of pure intersection relationships
and enclosure relationships can be determined.
This forms a list of relationship pairs from the cross product of all the contours.

\equation
%\label{crossprodsingle}
\begin{array}{l}
 pi(a,b) \; \Rightarrow
%\stackrel{\Delta}{=} 
  \; \forall    \;  C \; \bullet \; a   \;  X  \;   \forall C \; \bullet \; b  \\
 \;  \bullet   (a \cap b)  \; \wedge \; \neg (a \supseteq b) \; \wedge \; \neg  (b \supseteq a) \\
\end{array}
\endequation


\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 452 290,keepaspectratio=true]{fzd/pice.jpg}
 % pice.jpg: 628x403 pixel, 100dpi, 15.95x10.24 cm, bb=0 0 452 290
 \caption{Pure Intersection Chain with implicit enclosure}
 \label{fig:picwaie}
\end{figure}

% \begin{figure}
% \vskip 6cm
% \special{psfile=fzd/pice.ps hoffset=0 voffset=0 hscale=40 vscale=40}\caption[Pure Intersection Zone Capture Method]{
% Pure Intersection Chain with an implicit Enclosure
% \label{fig:picwaie}}
% \end{figure}

\subsection {Determining  Enclosure }

When a contour completely encloses another contour, it has an enclosing relationship.
See figure \ref{fig:piee}

To determine the enclosure relationships for the diagram,
 all contours are checked for enclosure relationships with each other.
This again, forms a list of relationship pairs from  cross product of all the contours.



\equation
%\label{crossprodsingle}
\begin{array}{l}
 enc(a,b) \; 
%\stackrel{\Delta}{=}
\Rightarrow \; \forall   \;  C \; \; \bullet a   \;  X  \;   \forall  \;  C   \; \bullet \; b  \\
 \;  \bullet   (a \supset b)   \\
\end{array}
\endequation


\section{The Pure Intersection Chain}

A pure intersection chain is isolated in terms of zone production.
If the number of contours in the chain is $nn$ then the maximum
number of zones within the chain can be $2^{nn}$.
If contours enclose the chain, the $A$ set defining the zones will
have the contours that enclose it, but the same number of
zones will be produced by examining the pure instersection chains with Area Comparisons.

\subsection { Rules that can be derived from the three relationships }

\subsection { Rule 1: Simple Zone Creation }

Any contour not belonging to a pure intersection chain, will create a zone containing itself, and any enclosing contours.

\subsection { Rule 2: All Pure Intersection chains and enclosures can be represented on a directed graph }

By displaying pure intersection relations and enclosure relations in different colours
both can be represented on the same coloured directed graph (CDG). I have chosen blue for pure
intersections and red for enclosures for the examples that follow.


Figure \ref{fig:pig1} Shows a CDG for the diagram in figure \ref{fig:pic}. Note that traversing through this graph reveals all the intersections, and that there are no loops in the traversal, meaning that no multiple intersections exist. 

\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 361 163]{fzd/pig1.jpg}
 % pig1.jpg: 502x227 pixel, 100dpi, 12.75x5.77 cm, bb=0 0 361 163
 \caption{Coloured Directed Graph of Pure Intersection Chain}
 \label{fig:pig1}
\end{figure}
% 
% \begin{figure}
% \vskip 6cm
% \special{psfile=fzd/pig1.ps hoffset=0 voffset=0 hscale=40 vscale=40}\caption[Pure Intersection Zone Capture Method]{
% Coloured Directed Graph of Pure Intersection Chain 
% \label{fig:pig1}}
% \end{figure}


\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 352 307,keepaspectratio=true]{fzd/pig2.jpg}
 % pig2.jpg: 489x427 pixel, 100dpi, 12.42x10.85 cm, bb=0 0 352 307
 \caption{Coloured Directed Graph of Pure Intersection Chain with an implicit enclosure}
 \label{fig:pig2}
\end{figure}
% 
% \begin{figure}
% \vskip 6cm
% \special{psfile=fzd/pig2.ps hoffset=0 voffset=0 hscale=40 vscale=40}\caption[Pure Intersection Zone Capture Method]{
% Coloured Directed Graph of Pure Intersection Chain with an implicit Enclosure
% \label{fig:pig2}}
% \end{figure}


\subsection { Graph Traversal }

By traversing the graphs and applying tests for implicit enclosure within a pure intersection chain
from each contour belonging to it, and applying any enclosure relations all possible 
zone combinations are revealed.
A path may not loop, i.e. it cannot branch to a contour all ready examined in the path.

\subsection{ Rule 3: Traversal Reduction : Avoiding Repeated Area checking }
As each potential zone is discovered and checked it is temporarily stored,
 and if re-discovered on a new path, is not subjected to Area testing.

\subsection { Rule 4: Pure Intersection Pair Zone Creation }

If any pure intersection exists, a potential zone exists. This zone
will intersect with any contour which has an enclosure relationship with 
any of the pair in the pure intersection.
It may also be enclosed by a member of the pure intersection chain it belongs to.
Thus where a pair intersection exists, checking for its existence is unnecessary, 
but checking for obscuration is.
\par
Note by only searching within the pure intersection chain, unnecessary obscuration tests are avoided
and this refines the obscuration test in equation \ref{available7}.
\par
If a zone does not belong to a pure intersection chain, no obscuration testing is necessary.
\par
Note : In figure \ref{fig:picwaie} note that contours \em{D} and \em{E} are in
 the same pure intersection chain, but that
\em{E} also encloses \em{D}.




\subsection { Rule 5: Multiple Zone Creation }


A circular reference (often described as a circuit \cite{gtl} \cite{alggraph}) containing more than one pair of pure intersections
 indicates the possibility
of a multiple  intersection of the contours in the path. The converse is true. 
Should there be no circular path, there can be 
multiple intersection along this path.
\par
This is best shown as an example, see figures \ref{fig:abc1}, \ref{fig:abc2} and \ref{fig:abc3}.
 Consider the three contours A, B and C.
These belong to the same pure intersection chain, 
and the graph has a circular reference. However one contains a an $ A \cap B \cap C $
 zone and the other does not.
\par 
Multiple intersections due to enclosure are discovered by traversing the 
enclosure relations.
\par

\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 375 377,keepaspectratio=true]{fzd/abc1.jpg}
 % abc1.jpg: 521x524 pixel, 100dpi, 13.23x13.31 cm, bb=0 0 375 377
 \caption{circular Reference with multiple zone}
 \label{fig:abc1}
\end{figure}
% 
% \label{fzd}
% \begin{figure}
% \vskip 6cm
% \special{psfile=fzd/abc1.eps hoffset=0 voffset=0 hscale=60 vscale=60}\caption[Pure Intersection Zone Capture Method]{
% Circular reference with multiple zone
% \label{fig:abc1}}
% \end{figure}

\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 390 371]{fzd/abc2.jpg}
 % abc2.jpg: 542x515 pixel, 100dpi, 13.77x13.08 cm, bb=0 0 390 371
 \caption{Circular reference without multiple zone}
 \label{fig:abc2}
\end{figure}
% 
% \label{fzd}
% \begin{figure}
% \vskip 6cm
% \special{psfile=fzd/abc2.eps hoffset=0 voffset=-20 hscale=60 vscale=60}\caption[Pure Intersection Zone Capture Method]{
% Circular reference without multiple zone
% \label{fig:abc2}}
% \end{figure}

\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 642 482,keepaspectratio=true]{fzd/abcgraph.jpg}
 % abcgraph.jpg: 891x669 pixel, 100dpi, 22.63x16.99 cm, bb=0 0 642 482
 \caption{Pure Intersection Zone and Enclosure}
 \label{fig:abdgraph}
\end{figure}
% 
% \label{fzd}
% \begin{figure}
% \vskip 6cm
% \special{psfile=fzd/abcgraph.ps hoffset=0 voffset=-10 hscale=30 vscale=30}\caption[Pure Intersection Zone Capture Method]{
% Pure Intersection Zone and Enclosure
% \label{fig:abcgraph}}
% \end{figure}

In order to examine multiple intersections, the spanning tree from the contour under inspection must be 
recursively iterated (only within the pure intersection chain it belongs to i.e. within the subset $G$).

Should a path arrive back at its start vertex, a circular reference has been found
and there is the possibility of a multiple intersection zone, see figure \ref{fig:abcgraph}.
\par
Note that the contour maps for {A,B,C} in figure \ref{fig:abc1} and \ref{fig:abc2}
are identical. The actual presence of the multiple intersection zone existing in the concrete diagram, must be tested for
using area comparisions.
The test must use coordinates from the concrete diagram to perform an Area comparison.
\par
However, by only searching for them when a circular path is found, unnecessary searches are not undertaken.
This is the principal strength of this algorithm. 

This will eliminate most non visible zones from requiring area searches.

\subsection{Zone Obscuration Test}

A zone enclosed by a member of its pure intersection, or enclosed completely will
 be correctly cwdiscovered by the recursive and iterative process. However, it is possible that two or
 more contours may combine to obscure a contour. This must be tested for, by
 taking the area intersection of all contours comprising the potential zone, 
and then subtracting all other areas. If any area remains, the zone is unobscured.
\par
Note that the obscuration test only need be applied within the pure intersection chain.
This is because a contour can only have a pure intersection chain or enclosure relationship with any other contour.
If the contour is enclosed it simply adds to the 'included ' contours.
Now only one (or more members in combination) of the same pure intersection chain can obscure a zone within it.
This reduces the number of obscuration tests to perform.

\par
If a zone is discovered and is not obscured, it is deemed a visible zone see equations \ref{available1},\ref{available2},\ref{available3},\ref{available4}.


\section{ Graph Traversal and Algorithm Development }

Using the rules from the previous section and some dry runs of the 
procedure an efficient recursive algorithm has been developed.
Essentially, a spanning tree is created originating from each contour 
in the diagram, using the pure intersection relationships.

\subsection { Traversal of a Simple Pure Intersection Chain }

Starting with the pure intersection chain in figure \ref{fig:pic}, with the contour A.
 Note that create zone -or- CZ means that the potential zone, with intersecting elements
is checked for enclosure by all contours in the diagram with an enclosing relationship, and then 
specifically created as an Area\cite{javaarea}, and this Area object is checked for 
existence and for obscuration. NP means a repeated path, where zones rediscovered will not be 
re-investigated as area objects.
\par
Iteration 1. Contour A
$$
\begin{array}{lclcl}
A  & &  & CZ & A \\
A & \stackrel{pi}\longrightarrow & B  & CZ & A \cap B \\
B & \stackrel{pi}\longrightarrow & C  & CZ & B \cap C\\
C & \stackrel{pi}\longrightarrow & D  & CZ & C \cap D \\
\end{array}
$$
Note the individual case of A is considered, and then on through the chain of pure intersections. 
Contour A is now marked as processed.
Next contour B is processed. 
\par
Iteration 2. Contour B
$$
\begin{array}{lclcl}
B & & & CZ & B\\
B & \stackrel{pi}\longrightarrow & A  & NP  \\
B & \stackrel{pi}\longrightarrow & C  & CZ &  B \cap C \\
C & \stackrel{pi}\longrightarrow & D  & CZ &  C \cap D\\
\end{array}
$$
Iteration 3. Contour C
$$
\begin{array}{lclcl}
C & & & CZ & C\\
C & \stackrel{pi}\longrightarrow & B  & NP &   \\
C & \stackrel{pi}\longrightarrow & D  & CZ & C \cap D  \\
\end{array}
$$

Iteration 4. Contour D
$$
\begin{array}{lclcl}
D & & & CZ &  D \\
D & \stackrel{pi}\longrightarrow & C  & NP   \\
\end{array}
$$

Using these iterations we have found all seven zones and only rediscovered 
three during the iterations. 
Only simple area searches were used to build the relation tables,
 also for a brute for concrete area compare method,
we would have had to examine  $ 2^{N} $ or 16 searches with an average of 4 compares (64 operations).

\subsection { Traversal of a Pure Intersection Chain with Implicit Enclosure }

The iteration for the diagram in figure  \ref{fig:picwaie} is very similar to that
above, but the zones $ D \cup E \cup C $ would be created because of checking for enclosure within 
a pure intersection chain, and $ C \cup E $ following the pure intersection path 
$ C \; \stackrel{pi}\longrightarrow \;  D $ and the standalone zone $ E $.


\subsection { Traversal of a Pure Intersection Chain with Circular Reference }

Here we encounter the possibility of a multiple intersection zone. The {\em CZ} action
must find the intersection, and then check that it really exists using area compares.
The iteration chain then for Figure \ref{fig:abc1} or \ref{fig:abc2}.

\par
Iteration 1. Contour A
$$
\begin{array}{lclcl}
A  & &  & CZ & A \\
A & \stackrel{pi}\longrightarrow & B  & CZ & A \cap B \\
B & \stackrel{pi}\longrightarrow & C  & CZ & B \cap C \\
C & \stackrel{pi}\longrightarrow & A  & CZ & C \cap A \\
C & \stackrel{pi}\longrightarrow & C  & CZ & B \cap C \cap A \\
\end{array}
$$
Note the last iteration has discovered a circular path. The CZ action will now investigate the presence 
of the $ B \cap C \cap A $ intersection and register it if it is in the concrete diagram.

Iteration 2. Contour B.
$$
\begin{array}{lclcl}
B  & &  & CZ & B \\
B & \stackrel{pi}\longrightarrow & A  & NP &  \\
B & \stackrel{pi}\longrightarrow & C  & NP &  \\
\end{array}
$$

Iteration 3. Contour C.
$$
\begin{array}{lclcl}
C & &  & CZ & C \\
C & \stackrel{pi}\longrightarrow & A  & NP &  \\
C & \stackrel{pi}\longrightarrow & B  & NP &  \\
\end{array}
$$
So, using the unordered relationships, determined by individual area compares, we are able to determine the 
7 visible zones by graph traversal, and one Area check (for $ A \cup B\cup C $).

\section{Algorithm Efficiency : Iteration Comparisons against Brute Force Method}
\label{complexity}
The examples show in diagram form here use 8 contours per diagram. Using the Brute force method these would require $N 2^{N}$ or
2048 area compares to determine all visible zones.
By duplicating the structures, iteration values can be calculated for 16 contour diagrams of the same visual complexity.

\subsection { Simple pairs of contours}

The simple diagram, shown in figure \ref{fig:simple}, consists of four 
overlapping pairs of contours. To determine the
 enclosure and pure intersection relations, two cross products of area 
searches are required. Thus $2 \;N^{2} $, i.e. 128 searches.
\par
Zones derived from single or pair contours do not need to be checked for existence. The pure intersection
 relation has already determined the pair zone exists and a single contour always creates a zone. 
Checking is required for obscuration is not required because none of the contours belong to a pure intersection.
\par
The total number of area compares/operations is therefore $2.64 \equiv 128 $
\par
As a general case, for extrapolating larger diagrams of the same pattern

\equation
\label{gensp}
2.N^{2}
\endequation



\begin{figure}
\vskip 6cm
\special{psfile=fzd/simple.ps hoffset=0 voffset=-10 hscale=40 vscale=40}\caption[Simple Pure Intersection Pairs]{
Simple Pure Intersection Pairs
\label{fig:simple}}
\end{figure}

\subsection {Two Venn 3 totally Enclosed Once : a more Complex Diagram}

The second diagram, see figure \ref{fig:tev3}, contains two Venn 3 configurations each enclosed by a contour.
Breaking this down, we have two single zones (i.e. G and H). These do not belong to a pure intersection chain and therefore require tests no for obscuration.
\par
Examining the two Venn3 structures, these require an existance check for the tripple intersection ( 3 area operations ). As the number of 
contours to check for obscuration against it is 0, they do not obscuration testing.
\par
The 3 pairs require obscuration testing with the other countour. Thus 2 area operations to construct the shape of the zone,
and 1 area operation to test for obscuration, thus 3  per pair.
\par
The three single zones in the pure intersection require 1 area operation to construct the shape of the contour, and two to test for obscuration.
Thus 3 per pair.



This diagram therefore requires $128 + 2.(9 + 9) \equiv 146  $ area compares.



\equation
\label{genev3}
2.N^{2}  + \frac{N}{4}.(18)  
\endequation


\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 585 410,keepaspectratio=true]{fzd/tripples.jpg}
 % tripples.jpg: 813x569 pixel, 100dpi, 20.65x14.45 cm, bb=0 0 585 410
 \caption{Two Enclosed Venn 3}
 \label{fig:tev3}
\end{figure}
% 
% \begin{figure}
% \vskip 6cm
% \special{psfile=fzd/tripples.ps hoffset=0 voffset=-10 hscale=40 vscale=40}\caption[Two Enclosed Venn 3]{
% Two Enclosed Ven 3
% \label{fig:tev3}}
% \end{figure}


\subsection {Extrapolating for N Contour Diagrams}

Duplicating the structures in the diagrams in figures  \ref{fig:tev3} and \ref{fig:simple},
 and using the general
case equations (\ref{genev3} and \ref{gensp}), a plot of area searches required 
against diagram complexity
can be drawn. These graphs clearly shows that the fzd method efficiency increases with the 
number of contours in a diagram. 

\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 414 308,keepaspectratio=true]{fzd/perf1.jpg}
 % perf1.jpg: 575x428 pixel, 100dpi, 14.60x10.87 cm, bb=0 0 414 308
 \caption{Performace from 0 to 8 contours}
 \label{fig:perf1}
\end{figure}

% \begin{figure}
% \vskip 6cm
% \special{psfile=fzd/perf1.ps hoffset=0 voffset=-10 hscale=60 vscale=60}\caption[Performance Comparison]{
% Perfomance from 0 to 8 contours
% \label{fig:perf1}}
% \end{figure}

\begin{figure}[h]
 \centering
 \includegraphics[width=200pt,bb=0 0 414 308,keepaspectratio=true]{fzd/perf2.jpg}
 % perf2.jpg: 575x428 pixel, 100dpi, 14.60x10.87 cm, bb=0 0 414 308
 \caption{Performace from 8 to 64 contours}
 \label{fig:perf2}
\end{figure}

% \begin{figure}
% \vskip 6cm
% \special{psfile=fzd/perf2.ps hoffset=0 voffset=-10 hscale=60 vscale=60}\caption[Performance Comparison]{
% Performance from 8 to 64 contours
% \label{fig:perf2}}
% \end{figure}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ALREADY DONE ! Obscuration is now only looked at within pure intersection chains.
% 05AUG2006
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% \subsection { A general Case and Algorithm efficiency plotted against number of Contours }

% \subsection {Further Optimisation}

% If sections of the diagram can be identified that do not interact (enclose or purely intersect with other parts)
% these can be analysed separately and reduce the $I$ and $O$ values. For instance in the Venn3 enclosed once,
%  the tests for existence and obscuration, need only be applied within each of the two identical
%  (in the abstract sense) separate structures.  This would  make the set G, discussed in equation \ref{seteq} 
% half the size of the number of contours in the diagram. Work on identifying separate areas and the
% potential for nesting Euler diagrams is discussed in \cite{nied}.



% \equation
% \label{gopt}
% \begin{array}{l}
% G_{optimal} \; \stackrel{\Delta}{=}   \; \forall    \;  C \; \bullet \; a   \;  X  \;   \forall \; C \; \bullet \; b  \\
%  \;  \bullet  (a  \stackrel{pi}\longrightarrow  b)  \; \vee \;  (a \stackrel{enc}\longrightarrow  b) \; \vee \;
%   (b \stackrel{enc}\longrightarrow a) \\
%:wq
%:wq \end{array}
% \endequation

% The optimal G sets are those within the diagram connected by any pure intersection or enclosure relationship.
% This is expressed formally in equation \ref{gopt}.

% \parsep=0pt
% \itemsep=0pt
% \parskip=3pt
% 
% \small
% \begin{thebibliography}{119}
% 
% 
% 
% \bibitem{javaapp1} Gosling et. all {\em The Java Application Programming Interface Vol I : Addisson Wesley : ISBN 0 201 63453 8 }
% 
% \bibitem{javaapp2} Gosling et. all {\em The Java Application Programming Interface Vol II : Addisson Wesley : ISBN 0 201 63459 7 }
% 
% \bibitem{fft}  Robert D Stum, Donald E Kirk {\em Discrete Systems and Digital  Signal Processing : Addison-Wesley : ISBN 0-201-09518-1 }
% 
% \bibitem{sem} Jim Woodcock, Martin Loomes {\em Software Engineering Mathematics : Pitman : ISBN 0-273-02673-9 }
% 
% \bibitem{alggraph} Alan Gibbons {\em Algorithmic Graph Theory : Cambridge University Press : ISBN 0-521-28881-9 }
% 
% 
% \bibitem{gtl} Cadwell {\em http://www.utm.edu/cgi-bin/caldwell/tutor/departments/math/graph/intro}
% 
% \bibitem{dmnt} R Garnier, J Taylor {\em Discrete Mathematics for New Technology : IoP : ISBN 0-7503-0135-X }
% 
% \bibitem{dmfss} D C Ince {\em An Introduction to Discrete Mathematics, Formal System Specification and Z : Oxford :  ISBN 0-19-853836-7 }
% 
% \bibitem{wiki} R.P. Clark et. all  {\em http://en.wikipedia.org/wiki/Euler\_diagram : Wikipedia Euler Diagram reference }
% 
% \bibitem{nied} J.A. Flower, J Howse, J Taylor {\em Nesting in Euler Diagrams } http://www.cmis.brighton.ac.uk/Research/vmg/papers/GTVMT02.pdf
% 
% \bibitem{cried} Howse J, Stapleton G, Flower J, Taylor J {\em Corresponding regions in Euler diagrams} http://www.cmis.brighton.ac.uk/Research/vmg/papers/D2K2HSFT.pdf
% 
% \bibitem{geneuler} Jean Flower, John Howse {\em Generating Euler Diagrams :Proceedings of Diagrams 2002, Callaway Gardens, Georgia, April 2002, Springer Verlag } http://www.it.bton.ac.uk/research/vmg/VisualModellingGroup.html
% 
% \bibitem{javaarea} Sun Micro Systems {\em http://java.sun.com/j2se/1.3/docs/api/java/awt/geom/Area.html }
% 
% \end{thebibliography}
% 

%\end{document}

%\theend





