You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BuildFacebookData.m 558B

5 years ago
1234567891011121314151617181920
  1. function [data] = BuildFacebookData(graph)
  2. graph_size = size(graph,2);
  3. all_nodes = zeros(1,graph_size);
  4. for i = 1:graph_size
  5. all_nodes(1,i) = graph{i}(1);
  6. end
  7. data = sparse(graph_size, graph_size); %TODO change to graph size
  8. for i = 1:graph_size
  9. node_idx = find(all_nodes == graph{i}(1));
  10. for j = 2:size(graph{i},2)
  11. neighbor_idx = find(all_nodes == graph{i}(j));
  12. if size(neighbor_idx,2) > 0
  13. data(node_idx, neighbor_idx) = 1;
  14. data(neighbor_idx,node_idx) = 1;
  15. end
  16. end
  17. end
  18. end