# Model a graph of Persons with relationships like "is friend of"
We need to implement a service for building the list of all the
friends of the friends of a person.
```java
class Person {
String id;
String name;
}
class Relationship {
String type;
String personAId;
String personBId;
}
class Service {
static String FRIEND = "friend"
List<Person> pers;
List<Relationship> rels;
public List<String> findDirectFriends(Person person) {
List<String> friendsOf;
//
for (i=0; i<rels.size; i++){
if((rels.get(i).personAId.equals(person.id) || )&& rels.get(i).type.equals(FRIEND)){
//search person by id
fiendsOf.add(rels.get(i).personBId)
}
}
return friendsOf;
}
String [5] names ={"Laura","Camilo","Harold","Maria","Marta"};
0 1 2 3 4
//0,1
//1 family
//2 Friends
//3 boss
//0 no related
Person [5][5] relations= {
L C
L {1,2,1,2,1},
C {1,1,2,2,0},
{1,2,2,0,1}
{1,1,2,2,0},
{1,2,2,0,1}
};
for (i=0;i<names[].length,i++){
}
for (int i=0; i<names.length, i++){
for(){
}
}
}
```