java - How to map knowledge statements/relationships from text file to (directed) graph -


i have following data in .txt file, need map graph have no real idea how that? mean formatting. not allowed change data in file, need map vertices/edges not know how take part of string(from line in text file) , map edge end of string? if makes sense?

this text file in question

any great. thanks!

trout is-a fish fish has gills fish has fins fish food fish is-an animal apple is-a fruit fruit has stem fruit food fruit is-a vegetable animal is-a living-thing vegetable is-a living-thing cod is-a fish trout lives-in freshwater cod lives-in saltwater tiger is-a cat tiger has stripes tiger wild tabbie is-a cat tabbie has stripes tabbie is-a pet flag has stripes flag is-an artifact cat is-a mammal mammal is-an animal dog is-a mammal 

for each line, split on space.

string[] lineparts = line.split(" "); 

you'll have relation type in lineparts[1] example. can use parts 0 , 2 build graph in datastructure chose.