using System.Collections.Generic;
public Vertex( int _id, string _content )
public EndVertex( int _id, string _content )
public class ConditionVertex
public ConditionVertex( int _id, string _content )
public Vertex m_trueBranch;
public Vertex m_falseBranch;
public struct PathElement
public PathElement( ConditionVertex _conditionVertex, bool _conditionValue )
m_conditionVertex = _conditionVertex;
public void setValue( bool _value )
public bool isBothValues()
return m_isTrue && m_isFalse;
public ConditionVertex m_conditionVertex;
public Path( EndVertex _endVertex )
m_endVertex = _endVertex;
m_elements = new List< PathElement > ();
public void addElement( PathElement _element )
Nullable< PathElement > existingPathElement = findPathElement( _element.m_conditionVertex );
if ( !existingPathElement.HasValue )
m_elements.Add( _element );
PathElement newPathElement = new PathElement( existingPathElement.Value.m_conditionVertex , existingPathElement.Value.isTrue() );
newPathElement.setValue( _element.isTrue() );
int elementIndex = findIndex( newPathElement.m_conditionVertex );
m_elements[ elementIndex ] = newPathElement;
public Nullable< PathElement > findPathElement( ConditionVertex _conditionVertex )
foreach ( PathElement it in m_elements )
if ( it.m_conditionVertex == _conditionVertex )
return new Nullable< PathElement >();
public int findIndex( ConditionVertex _conditionVertex )
int count = m_elements.Count;
for ( int i = 0; i < count; ++i )
if ( m_elements[ i ].m_conditionVertex == _conditionVertex )
public IEnumerable< PathElement > getPathElementsIterable()
foreach( PathElement it in m_elements )
public EndVertex m_endVertex;
private List< PathElement > m_elements;
m_vertexes = new Dictionary< int, Vertex >();
public void createEndVertex( int _id, string _content )
EndVertex newVertex = new EndVertex( _id, _content );
m_vertexes.Add( _id, newVertex );
public void createConditionVertex( int _id, string _content )
ConditionVertex newVertex = new ConditionVertex( _id, _content );
m_vertexes.Add( _id, newVertex );
public void setTrueBranch( int _conditionVertexId, int _vertexId )
ConditionVertex conditionVertex = getConditionVertex( _conditionVertexId );
Vertex vertex = getVertex( _vertexId );
conditionVertex.m_trueBranch = vertex;
public void setFalseBranch( int _conditionVertexId, int _vertexId )
ConditionVertex conditionVertex = getConditionVertex( _conditionVertexId );
Vertex vertex = getVertex( _vertexId );
conditionVertex.m_falseBranch = vertex;
public Vertex getVertex( int _id )
return m_vertexes[ _id ];
public ConditionVertex getConditionVertex( int _id )
Vertex vertex = getVertex( _id );
ConditionVertex conditionVertex = vertex as ConditionVertex;
if ( (object)conditionVertex == null )
public Vertex findVertex( int _id )
return m_vertexes[ _id ];
public bool hasVertex( int _id )
return m_vertexes.ContainsKey( _id );
public IEnumerable< Vertex > getVertexesIterable()
foreach( KeyValuePair< int, Vertex > it in m_vertexes )
public IEnumerable< ConditionVertex > getConditionVertexesIterable()
foreach( KeyValuePair< int, Vertex > it in m_vertexes )
ConditionVertex conditionVertex = it.Value as ConditionVertex;
if ( conditionVertex != null )
yield return conditionVertex;
private Dictionary< int, Vertex > m_vertexes;
public class PathsBuilder
public PathsBuilder( Graph _graph )
m_backwardConnections = new Dictionary< int, HashSet< int > >();
m_paths = new List< Path >();
setupBackwardConnections();
List< EndVertex > endVertexes = new List< EndVertex >();
foreach ( Vertex it in m_graph.getVertexesIterable() )
EndVertex endVertex = it as EndVertex;
if ( (object)endVertex != null )
endVertexes.Add( endVertex );
( EndVertex _ev1, EndVertex _ev2 ) =>
return _ev1.m_id - _ev2.m_id;
foreach ( EndVertex endVertex in endVertexes )
m_paths.Add( buildPath( endVertex ) );
public IEnumerable< Path > getPathsIterable()
foreach ( Path it in m_paths )
private Path buildPath( EndVertex _endVertex )
Path result = new Path( _endVertex );
buildPath( _endVertex, null, result );
private void buildPath( Vertex _currentVertex, Vertex _nextVertex, Path _targetPath )
ConditionVertex currentConditionVertex = _currentVertex as ConditionVertex;
if ( currentConditionVertex != null )
bool conditionBranch = getConditionVertexBranch( currentConditionVertex, _nextVertex );
_targetPath.addElement( new PathElement( currentConditionVertex, conditionBranch ) );
if ( !m_backwardConnections.ContainsKey( _currentVertex.m_id ) )
HashSet< int > backwardVertexIds = m_backwardConnections[ _currentVertex.m_id ];
foreach ( int backwardVertexId in backwardVertexIds )
ConditionVertex backwardVertex = m_graph.getConditionVertex( backwardVertexId );
buildPath( backwardVertex, _currentVertex, _targetPath );
private bool getConditionVertexBranch( ConditionVertex _conditionVertex, Vertex _vertex )
if ( _conditionVertex.m_falseBranch == _vertex )
if ( _conditionVertex.m_trueBranch == _vertex )
private void setupBackwardConnections()
foreach ( Vertex it in m_graph.getVertexesIterable() )
m_backwardConnections.Add( it.m_id, new HashSet< int >() );
foreach ( Vertex it in m_graph.getVertexesIterable() )
ConditionVertex conditionVertex = it as ConditionVertex;
if ( (object)conditionVertex != null )
m_backwardConnections[ conditionVertex.m_falseBranch.m_id ].Add( conditionVertex.m_id );
m_backwardConnections[ conditionVertex.m_trueBranch.m_id ].Add( conditionVertex.m_id );
private Dictionary< int, HashSet< int > > m_backwardConnections;
private List< Path > m_paths;
public struct TableLineElement
int _conditionVertexNumber
, double _positiveResultPossibility
, double _allOthersPossibleResultPossibility
m_conditionVertexNumber = _conditionVertexNumber;
m_positiveResultPossibility = _positiveResultPossibility;
m_allOthersPossibleResultPossibility = _allOthersPossibleResultPossibility;
public int m_conditionVertexNumber;
public double m_positiveResultPossibility;
public double m_allOthersPossibleResultPossibility;
public TableLine( EndVertex _endVertex, double _startPossibility )
m_endVertex = _endVertex;
m_startPossibility = _startPossibility;
m_conditionNumberToElement = new Dictionary< int, TableLineElement >();
public void addElement( TableLineElement _element )
if ( hasConditionNumber( _element.m_conditionVertexNumber ) )
m_conditionNumberToElement.Add( _element.m_conditionVertexNumber, _element );
public bool hasConditionNumber( int _conditionNumber )
return m_conditionNumberToElement.ContainsKey( _conditionNumber );
public IEnumerable< TableLineElement > getElementsIterable()
List< TableLineElement > m_sortesElements = new List< TableLineElement >();
foreach ( KeyValuePair< int, TableLineElement > it in m_conditionNumberToElement )
m_sortesElements.Add( it.Value );
( TableLineElement _e1, TableLineElement _e2 ) =>
return _e1.m_conditionVertexNumber - _e2.m_conditionVertexNumber;
foreach ( TableLineElement it in m_sortesElements )
public EndVertex m_endVertex;
public double m_startPossibility;
private Dictionary< int, TableLineElement > m_conditionNumberToElement;
m_lines = new List< TableLine >();
public void addLine( TableLine _line )
public IEnumerable< TableLine > getLinesIterable()
foreach ( TableLine it in m_lines )
private List< TableLine > m_lines;
public class StartPosibilitiesInfo
public StartPosibilitiesInfo( Graph _graph )
m_vertexToPossibilities = new Dictionary< EndVertex, double >();
public void setToDefault()
foreach ( Vertex vertex in m_graph.getVertexesIterable() )
EndVertex endVertex = vertex as EndVertex;
if ( (object)endVertex != null )
double startPossibility = 1.0 / (double) endVertexCount;
foreach ( Vertex vertex in m_graph.getVertexesIterable() )
EndVertex endVertex = vertex as EndVertex;
if ( (object)endVertex != null )
trackPossibility( endVertex.m_id, startPossibility );
public void trackPossibility( int _vertexId, double _possibility )
Vertex vertex = m_graph.getVertex( _vertexId );
EndVertex endVertex = vertex as EndVertex;
m_vertexToPossibilities.Add( endVertex, _possibility );
public double getPossibility( EndVertex _endVertex )
return m_vertexToPossibilities[ _endVertex ];
private Dictionary< EndVertex, double > m_vertexToPossibilities;
public class TableBuilder
public TableBuilder( Graph _graph, StartPosibilitiesInfo _startPossibilitiesInfo )
m_startPossibilitiesInfo = _startPossibilitiesInfo;
m_paths = new List< Path >();
m_vertexToConditionNumber = new Dictionary< ConditionVertex, int >();
setupVertexToCondittionNumbersCollection();
private void setupPaths()
PathsBuilder pathsBuilder = new PathsBuilder( m_graph );
m_paths.AddRange( pathsBuilder.getPathsIterable() );
private void setupVertexToCondittionNumbersCollection()
List< ConditionVertex > conditionVertexes = new List< ConditionVertex >();
foreach ( Vertex it in m_graph.getVertexesIterable() )
ConditionVertex conditionVertex = it as ConditionVertex;
if ( (object)conditionVertex != null )
conditionVertexes.Add( conditionVertex );
( ConditionVertex _cv1, ConditionVertex _cv2 ) =>
return _cv1.m_id - _cv2.m_id;
int count = conditionVertexes.Count;
for ( int i = 0; i < count; ++i )
m_vertexToConditionNumber.Add( conditionVertexes[ i ], i+1 );
int pathsCount = m_paths.Count;
for ( int i = 0; i < pathsCount; ++i )
m_table.addLine( buildTableLine( m_paths[ i ], i, false ) );
private TableLine buildTableLine( Path _path, int _pathIndex, bool _fullMode )
? buildFullTableLine( _path, _pathIndex )
: buildTableLine( _path, _pathIndex )
private TableLine buildTableLine( Path _path, int _pathIndex )
TableLine tableLine = new TableLine(
, m_startPossibilitiesInfo.getPossibility( _path.m_endVertex )
foreach ( PathElement it in _path.getPathElementsIterable() )
tableLine.addElement( buildTableLineElement( _path, it.m_conditionVertex, _pathIndex ) );
private TableLine buildFullTableLine( Path _path, int _pathIndex )
TableLine tableLine = new TableLine(
, m_startPossibilitiesInfo.getPossibility( _path.m_endVertex )
foreach ( ConditionVertex it in m_graph.getConditionVertexesIterable() )
tableLine.addElement( buildTableLineElement( _path, it, _pathIndex ) );
private TableLineElement buildTableLineElement( Path _path, ConditionVertex _conditionVertex, int _pathIndex )
return new TableLineElement(
m_vertexToConditionNumber[ _conditionVertex ]
, getAdjustedPossibility( getPositivePossibility( _path, _conditionVertex ) )
, getAdjustedPossibility( getAllOthersPositivePossibility( _path, _conditionVertex, _pathIndex ) )
private double getPositivePossibility( Path _path, ConditionVertex _conditionVertex )
Nullable< PathElement > optPathElement = _path.findPathElement( _conditionVertex );
if ( !optPathElement.HasValue )
return getDefaultPossibilityForNeverAskedQuestion();
if ( optPathElement.Value.isBothValues() )
return getDefaultPossibilityForNeverAskedQuestion();
return ( optPathElement.Value.isTrue() )
private double getAllOthersPositivePossibility( Path _path, ConditionVertex _conditionVertex, int _pathIndex )
double allOthersAmount = 1.0 - m_startPossibilitiesInfo.getPossibility( _path.m_endVertex );
double positiveAmount = 0.0;
int pathsCount = m_paths.Count;
for ( int i = 0; i < pathsCount; ++i )
Path currentPath = m_paths[ i ];
Nullable< PathElement > optCurrentPathElementWithSameConditio =
currentPath.findPathElement( _conditionVertex );
notAsked |= !optCurrentPathElementWithSameConditio.HasValue;
if ( optCurrentPathElementWithSameConditio.HasValue )
notAsked |= optCurrentPathElementWithSameConditio.Value.isBothValues();
double neverAskedPathPositiveAmount =
m_startPossibilitiesInfo.getPossibility( currentPath.m_endVertex )
* getDefaultPossibilityForNeverAskedQuestion()
positiveAmount += neverAskedPathPositiveAmount;
PathElement currentPathElementWithSameCondition = optCurrentPathElementWithSameConditio.Value;
if ( currentPathElementWithSameCondition.isBothValues() )
if ( currentPathElementWithSameCondition.isTrue() )
double pathAnsweringYesPositiveAmount = m_startPossibilitiesInfo.getPossibility( currentPath.m_endVertex );
positiveAmount += pathAnsweringYesPositiveAmount;
return positiveAmount / allOthersAmount;
private double getDefaultPossibilityForNeverAskedQuestion()
private double getMaxPossibility()
private double getMinPossibility()
public double getAdjustedPossibility( double _possibility )
if ( _possibility > getMaxPossibility() )
return getMaxPossibility();
if ( _possibility < getMinPossibility() )
return getMinPossibility();
private StartPosibilitiesInfo m_startPossibilitiesInfo;
private List< Path > m_paths;
private Dictionary< ConditionVertex, int > m_vertexToConditionNumber;
public class TablePrinter
public TablePrinter( Table _table, Graph _graph )
public List< string > execute()
List< string > result = new List< string >();
result.AddRange( printQuestions() );
foreach ( TableLine tableLine in m_table.getLinesIterable() )
result.Add( toString( tableLine ) );
public List< string > printQuestions()
List< string > questions = new List< string >();
List< ConditionVertex > conditionVertexes = new List< ConditionVertex >();
foreach ( ConditionVertex it in m_graph.getConditionVertexesIterable() )
conditionVertexes.Add( it );
( ConditionVertex _cv1, ConditionVertex _cv2 ) =>
return _cv1.m_id - _cv2.m_id;
int count = conditionVertexes.Count;
for ( int i = 0; i < count; ++i )
questions.Add( conditionVertexes[ i ].m_content );
public string toString( TableLine _tableLine )
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendFormat(
, getEndVertexContent( _tableLine.m_endVertex )
, _tableLine.m_startPossibility
foreach ( TableLineElement element in _tableLine.getElementsIterable() )
stringBuilder.AppendFormat(
stringBuilder.Length -= 2;
return stringBuilder.ToString();
public string toString( TableLineElement _element )
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendFormat(
, _element.m_conditionVertexNumber
, _element.m_positiveResultPossibility
, Math.Round( _element.m_allOthersPossibleResultPossibility, 3, MidpointRounding.AwayFromZero )
return stringBuilder.ToString();
public string getEndVertexContent( EndVertex _endVertex )
return _endVertex.m_content.Replace( ',', ';' );
public static Graph createExampleGraph()
Graph graph = new Graph();
graph.createEndVertex( y1id, "Y,1." );
graph.createEndVertex( y2id, "Y,2." );
graph.createEndVertex( y3id, "Y,3." );
graph.createEndVertex( y4id, "Y,4." );
graph.createEndVertex( y5id, "Y,5." );
graph.createConditionVertex( x1id, "X1?" );
graph.createConditionVertex( x2id, "X2?" );
graph.createConditionVertex( x3id, "X3?" );
graph.createConditionVertex( x4id, "X4?" );
graph.setFalseBranch( x1id, y1id );
graph.setTrueBranch( x1id, x2id );
graph.setFalseBranch( x2id, x4id );
graph.setTrueBranch( x2id, x3id );
graph.setFalseBranch( x3id, y3id );
graph.setTrueBranch( x3id, y2id );
graph.setFalseBranch( x4id, y5id );
graph.setTrueBranch( x4id, y4id );
public static Graph createV4()
Graph graph = new Graph();
graph.createConditionVertex( x1id, "BIOS register drive?" );
graph.createConditionVertex( x2id, "Set Master/Slave?" );
graph.createConditionVertex( x3id, "Set cable select(CS)?" );
graph.createConditionVertex( x4id, "Cable seated,new?" );
graph.createConditionVertex( x5id, "Drive seek, spin up?" );
graph.createConditionVertex( x6id, "IDE ribbon cable keyed?" );
graph.createConditionVertex( x7id, "CD or DVD drives?" );
graph.createConditionVertex( x8id, "Drive cycles up,down?" );
graph.createConditionVertex( x9id, "Mode, X-fer speed correct?" );
graph.createConditionVertex( x10id, "Does FDISK see drive?" );
graph.createEndVertex( y1id, "Select Master/Slave or CS. CS requires 80 conductor IDE cable or custom 40 wire cable");
graph.createEndVertex( y2id, "Reseat IDE and power cables. Replace IDE cables if in doubt." );
graph.createEndVertex( y3id, "Match pin 1 on all connerctors." );
graph.createEndVertex( y4id, "Try swapping cables and try drive in test PC before trashing." );
graph.createEndVertex( y5id, "Replace IDE cable. If BIOS still doesn't register drive, either motherboard controller or drive is bad or inconpatible." );
graph.createEndVertex( y6id, "Proceed to CD/DVD chart." );
graph.createEndVertex( y7id, "Swap power lead,try isolating on IDE cables,check power management." );
graph.createEndVertex( y8id, "New drives require 80 conductor cable,check mode in CMOS." );
graph.createEndVertex( y9id, "Isolate primary IDE controller. If FDISK still doesn't see drive, the MBR may have been trashed by a virus." );
graph.createEndVertex( y10id, "Proceed to Hard Drive Boot and Performance chart." );
graph.setFalseBranch( x1id, x2id );
graph.setTrueBranch( x1id, x7id );
graph.setFalseBranch( x2id, x3id );
graph.setTrueBranch( x2id, x4id );
graph.setFalseBranch( x3id, y1id );
graph.setTrueBranch( x3id, x4id );
graph.setFalseBranch( x4id, y2id );
graph.setTrueBranch( x4id, x5id );
graph.setFalseBranch( x5id, y4id );
graph.setTrueBranch( x5id, x6id );
graph.setFalseBranch( x6id, y3id );
graph.setTrueBranch( x6id, y5id );
graph.setFalseBranch( x7id, x8id );
graph.setTrueBranch( x7id, y6id );
graph.setFalseBranch( x8id, x9id );
graph.setTrueBranch( x8id, y7id );
graph.setFalseBranch( x9id, y8id );
graph.setTrueBranch( x9id, x10id );
graph.setFalseBranch( x10id, y9id );
graph.setTrueBranch( x10id, y10id );
public static Graph createV5()
Graph graph = new Graph();
graph.createEndVertex( y1id, "Download patch from software manufacture's website. Perform IDE Drive Failure diagnostics before continuing." );
graph.createEndVertex( y2id, "Check single-sided disc is upside down. Try new disc; try different brand; type." );
graph.createEndVertex( y3id, "Run on solo task. Check task list by ctrl-alt-del; close systray programs." );
graph.createEndVertex( y4id, "Data source is too slow( try Defrag hard drive ). Task being interrupted; or bumer; or media bad." );
graph.createEndVertex( y5id, "Try recording at 2X for CDs; 1X for DVDs." );
graph.createEndVertex( y6id, "Problem undetermined. Note some factory discs have copy protection that will produce unrelated errors." );
graph.createEndVertex( y7id, "Try using write-only media( CDR ); expesially for music CDs." );
graph.createEndVertex( y8id, "Music and movie CDs and DVDs must be recorded with proper format; in addition to media requirements and possible copy protection issues." );
graph.createConditionVertex( x1id, "Does recorder software see drive?" );
graph.createConditionVertex( x2id, "Software detect blank disk?" );
graph.createConditionVertex( x3id, "Starts recording process then fails?" );
graph.createConditionVertex( x4id, "Tried recording at lower speed?" );
graph.createConditionVertex( x5id, "Sole task?" );
graph.createConditionVertex( x6id, "Can read disk in other drive?" );
graph.createConditionVertex( x7id, "Music or movie disc?" );
graph.setFalseBranch( x1id, y1id );
graph.setTrueBranch( x1id, x2id );
graph.setFalseBranch( x2id, y2id );
graph.setTrueBranch( x2id, x3id );
graph.setFalseBranch( x3id, x6id );
graph.setTrueBranch( x3id, x4id );
graph.setFalseBranch( x4id, x5id );
graph.setTrueBranch( x4id, y5id );
graph.setFalseBranch( x5id, y3id );
graph.setTrueBranch( x5id, y4id );
graph.setFalseBranch( x6id, x7id );
graph.setTrueBranch( x6id, y6id );
graph.setFalseBranch( x7id, y7id );
graph.setTrueBranch( x7id, y8id );
public static Graph createVar8()
Graph graph = new Graph();
graph.createEndVertex(y1id, "Check crossover (X) port wiring.");
graph.createEndVertex(y2id, "Physical layer (cables, devices)");
graph.createEndVertex(y3id, "Clone setup from good workstation.");
graph.createEndVertex(y4id, "Proceed Conflict Resolution.");
graph.createEndVertex(y5id, "Swap cable or check pairs, ends.");
graph.createEndVertex(y6id, "Reboot, improper software configuration or bad network adapter.");
graph.createEndVertex(y7id, "In-wall cabling failure, limits, or hub port");
graph.createEndVertex(y8id, "Software limits, user settings");
graph.createEndVertex(y9id, "Check proper ground (one end)");
graph.createEndVertex(y10id, "Add repeaters, re-route cables.");
graph.createEndVertex(y11id, "Swap hub for switch, check server utilization.");
graph.createEndVertex(y12id, "If connection stable on new port, prior port is failing.");
graph.createEndVertex(y13id, "Proceed to Motherboard Perfomance.");
graph.createEndVertex(y14id, "Bad patch or in-wall cabling.");
graph.createEndVertex(y15id, "Throw out old adapter, $10 new.");
graph.createEndVertex(y16id, "Most likely software conflicts, virus.");
graph.createConditionVertex(x1id, "PC sees other network units?");
graph.createConditionVertex(x2id, "New hub added to LAN?");
graph.createConditionVertex(x3id, "Link light lit?");
graph.createConditionVertex(x4id, "Copied network config?");
graph.createConditionVertex(x5id, "Device Manager problem?");
graph.createConditionVertex(x6id, "Tried known good cable?");
graph.createConditionVertex(x7id, "PC works at new location?");
graph.createConditionVertex(x8id, "Random problems?");
graph.createConditionVertex(x9id, "Shielded cable?");
graph.createConditionVertex(x10id, "Within physical layer limits?");
graph.createConditionVertex(x11id, "Tried different port on hub?");
graph.createConditionVertex(x12id, "Fails on traffic, # of users?");
graph.createConditionVertex(x13id, "Flaky off network also?");
graph.createConditionVertex(x14id, "Cable bypass to hub fix?");
graph.createConditionVertex(x15id, "New network card works?");
graph.setFalseBranch( x1id, x2id );
graph.setTrueBranch( x1id, x8id );
graph.setFalseBranch( x2id, x3id );
graph.setTrueBranch( x2id, y1id );
graph.setFalseBranch( x3id, y2id );
graph.setTrueBranch( x3id, x4id );
graph.setFalseBranch( x4id, y3id );
graph.setTrueBranch( x4id, x5id );
graph.setFalseBranch( x5id, x6id );
graph.setTrueBranch( x5id, y4id );
graph.setFalseBranch( x6id, y5id );
graph.setTrueBranch( x6id, x7id );
graph.setFalseBranch( x7id, y6id );
graph.setTrueBranch( x7id, y7id );
graph.setFalseBranch( x8id, y8id );
graph.setTrueBranch( x8id, x9id );
graph.setFalseBranch( x9id, x10id );
graph.setTrueBranch( x9id, y9id );
graph.setFalseBranch( x10id, y10id );
graph.setTrueBranch( x10id, x11id );
graph.setFalseBranch( x11id, y12id );
graph.setTrueBranch( x11id, x12id );
graph.setFalseBranch( x12id, x13id );
graph.setTrueBranch( x12id, y11id );
graph.setFalseBranch( x13id, x14id );
graph.setTrueBranch( x13id, y13id );
graph.setFalseBranch( x14id, x15id );
graph.setTrueBranch( x14id, y14id );
graph.setFalseBranch( x15id, y16id );
graph.setTrueBranch( x15id, y15id );
public static Graph createHardExample()
Graph graph = new Graph();
graph.createEndVertex( y1id, "Y1." );
graph.createEndVertex( y2id, "Y2." );
graph.createEndVertex( y3id, "Y3." );
graph.createEndVertex( y4id, "Y4." );
graph.createConditionVertex( x1id, "X1?" );
graph.createConditionVertex( x2id, "X2?" );
graph.createConditionVertex( x3id, "X3?" );
graph.createConditionVertex( x4id, "X4?" );
graph.setFalseBranch( x1id, x2id );
graph.setTrueBranch( x1id, x3id );
graph.setFalseBranch( x2id, y1id );
graph.setTrueBranch( x2id, x4id );
graph.setFalseBranch( x3id, x4id );
graph.setTrueBranch( x3id, y4id );
graph.setFalseBranch( x4id, y2id );
graph.setTrueBranch( x4id, y3id );
public static void Main()
Graph graph = createVar8();
StartPosibilitiesInfo startPosibilitiesInfo = new StartPosibilitiesInfo( graph );
startPosibilitiesInfo.setToDefault();
TableBuilder tableBuilder = new TableBuilder( graph, startPosibilitiesInfo );
TablePrinter tablePrinter = new TablePrinter( tableBuilder.getTable(), graph );
List< string > tableText = tablePrinter.execute();
foreach( string it in tableText )
Console.WriteLine( "{0}", it );