Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class Grafo {
- private ArrayList<Nodo> nodi;
- private Arco[][] matriceAdiacenza;
- public boolean grafoProprio(Grafo g) {
- for (int i = 0; i< matriceAdiacenza.length ; i++) {
- if (!nodi.get(i).isUtente()) { // Il nodo è un brand
- for (int j = 0; j< matriceAdiacenza[i].length ; j++) {
- if (!nodi.get(j).isUtente() && matriceAdiacenza[i][j] == 1) {
- return false;
- }
- }
- }
- }
- return true;
- }
- public Collection influencer(Grafo g, Utente u) {
- ArrayList<Nodo> listBrand = new ArrayList<Nodo> ();
- int index = nodi.indexOf(u);
- int contaUtenti = 0;
- int contaBrand = 0;
- for (int i = 0; i < matriceAdiacenza[index].length; i++) {
- if (matriceAdiacenza[index][i] == 1) {
- if (nodi.get(i).isUtente()) {
- contaUtenti++;
- }
- else {
- contaBrand++;
- listBrand.add(nodi.get(i));
- }
- }
- }
- if (contaUtenti > contaBrand) {
- return listBrand;
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement