private static DefaultDirectedGraph < ObjectPropertyExpression , DefaultEdge > getObjectPropertyGraph ( OntologyImpl . UnclassifiedOntologyTBox ontology ) { DefaultDirectedGraph < ObjectPropertyExpression , DefaultEdge > graph = new DefaultDirectedGraph <> ( DefaultEdge . class ) ; for ( ObjectPropertyExpression role : ontology . objectProperties ( ) ) { if ( ! role . isBottom ( ) && ! role . isTop ( ) ) { graph . addVertex ( role ) ; graph . addVertex ( role . getInverse ( ) ) ; } } for ( ObjectPropertyExpression role : ontology . getAuxiliaryObjectProperties ( ) ) { graph . addVertex ( role ) ; graph . addVertex ( role . getInverse ( ) ) ; } ObjectPropertyExpression top = null ; // property inclusions for ( BinaryAxiom < ObjectPropertyExpression > roleIncl : ontology . getSubObjectPropertyAxioms ( ) ) { if ( roleIncl . getSub ( ) . isBottom ( ) || roleIncl . getSuper ( ) . isTop ( ) ) continue ; if ( roleIncl . getSuper ( ) . isBottom ( ) ) { throw new RuntimeException ( "BOT cannot occur on the LHS - replaced by DISJ" ) ; } if ( roleIncl . getSub ( ) . isTop ( ) ) { top = roleIncl . getSub ( ) ; graph . addVertex ( top ) ; } // adds the direct edge and the inverse (e.g., R ISA S and R- ISA S-) graph . addEdge ( roleIncl . getSub ( ) , roleIncl . getSuper ( ) ) ; graph . addEdge ( roleIncl . getSub ( ) . getInverse ( ) , roleIncl . getSuper ( ) . getInverse ( ) ) ; } if ( top != null ) { for ( ObjectPropertyExpression ope : graph . vertexSet ( ) ) graph . addEdge ( ope , top ) ; } return graph ; }
graph representation of object property inclusions in the ontology