You can optionally specify starting objects for the graph expansion, so that the expansion is limited to the selected starting objects. For example:
' Specify a starting object
Dim lobjStartingObj As IObject = SPFRequestContext.Instance.ProcessCache("RL_Viewer")
Dim lcolObjToExpand As New StructuredObjectCollection
lcolObjToExpand.Add(lobjStartingObj
For Each lobjItem As StructuredObject In lcolObjToExpand
lobjGraphExpansionQuery.AddSourceObject(lobjItem)
Next
If you do not specify any starting objects, the starting interface and any criteria on the starting graph node are used to determine the starting objects set. For more information on how to build object criteria, Using the Dynamic Query in the Data Access Layer (DAL).