public < T extends Relation > T add ( T statement , int num , Collection < T > anonRelationCollection , HashMap < QualifiedName , Collection < T > > namedRelationMap , HashMap < QualifiedName , Collection < T > > effectRelationMap , HashMap < QualifiedName , Collection < T > > causeRelationMap ) { QualifiedName aid2 = u . getEffect ( statement ) ; //wib.getInformed(); QualifiedName aid1 = u . getCause ( statement ) ; //wib.getInformant(); statement = pFactory . newStatement ( statement ) ; // clone QualifiedName id ; if ( statement instanceof Identifiable ) { id = ( ( Identifiable ) statement ) . getId ( ) ; } else { id = null ; } if ( id == null ) { boolean found = false ; Collection < T > relationCollection = effectRelationMap . get ( aid2 ) ; if ( relationCollection == null ) { relationCollection = new LinkedList < T > ( ) ; relationCollection . add ( statement ) ; effectRelationMap . put ( aid2 , relationCollection ) ; } else { for ( T u : relationCollection ) { if ( u . equals ( statement ) ) { found = true ; statement = u ; break ; } } if ( ! found ) { relationCollection . add ( statement ) ; } } relationCollection = causeRelationMap . get ( aid1 ) ; if ( relationCollection == null ) { relationCollection = new LinkedList < T > ( ) ; relationCollection . add ( statement ) ; causeRelationMap . put ( aid1 , relationCollection ) ; } else { if ( ! found ) { // if we had not found it in the first table, then we // have to add it here too relationCollection . add ( statement ) ; } } if ( ! found ) { anonRelationCollection . add ( statement ) ; } } else { Collection < T > relationCollection = namedRelationMap . get ( id ) ; if ( relationCollection == null ) { relationCollection = new LinkedList < T > ( ) ; relationCollection . add ( statement ) ; namedRelationMap . put ( id , relationCollection ) ; } else { boolean found = false ; for ( T u1 : relationCollection ) { if ( sameEdge ( u1 , statement , num ) ) { found = true ; mergeAttributes ( u1 , statement ) ; break ; } } if ( ! found ) { relationCollection . add ( statement ) ; } } } return statement ; }
Add an edge to the graph . Update namedRelationMap effectRelationMap and causeRelationMap accordingly . Edges with different attributes are considered distinct .