Database Reference
In-Depth Information
John's close friends, putting them at the top of the result list. You'd expect the same tra-
versal results as before, but in a specific order (different than before):
1 . Alien (as recommended by John's friend Emma)
2 . Fargo (as recommended by Kate, who is John's work colleague)
You can easily order relationships by type prior to expansion by using
OrderedByTypeExpander instead of the default StandardExpander , as the next
listing shows.
Listing 8.4. Expanding relationships in the order of relationship types
You instantiate the new expander using its default constructor
; then you add the rela-
tionshiptypetofollow .Thespecifiedrelationshiptypesareguaranteedtobeexpanded
in the same order as they're added to the expander, for every visited node. Because you
wantthe IS_FRIEND_OF relationshipstoalwaysbetraversedfirst,youadditfirstinyour
code.
Search WWH ::




Custom Search