%{
*********************************************************** 
(c) Ian Davidson and Davidson Lab. Please cite 

The Cluster Description Problem-Complexity Results, Formulations and Approximati
ons, I Davidson, A Gourru and SS. Ravi
Advances in Neural Information Processing Systems, 2018, 6191-6201
***********************************************************
%}

%% usa-880 data
% T = load('StructuralUserHashtagIUR.csv'); % Says what users used what hashtags its n x t
% T(T > 1) = 1;
% nodeNames = importdata('nodesUserIUR.csv'); % Names of users n x str
% c = load('Comm1Indicies.csv') + 1;
% hashtags = readtable('nodesHashtagUSA.csv');
% tagNames = table2array(hashtags);

%% usa-10k data
% T = load('StructuralUserHashtagUSA.csv'); % Says what users used what hashtags its n x t
% T(T > 1) = 1;
% nodeNames = importdata('nodesUSA.csv'); % Names of users n x str
% c = csvread('comUSA.csv', 1, 2);
% hashtags = readtable('nodesHashtagUSA.csv');
% tagNames = table2array(hashtags);

%% France-10k data
% T = load('StructuralHashtagsFrance.csv'); % Says what users used what hashtags its n x t
% T(T > 1) = 1;
% nodeNames = importdata('nodesFrance.csv'); 
% nodeNames = nodeNames.textdata; % Names of users n x str
% c = csvread('comFrance.csv', 1, 2);
% hashtags = readtable('nodesHashtagsFrance.csv');
% tagNames = table2array(hashtags);

%% usa_mounth data
file = 'ByMounths/actUSAMounth8.csv';
T = importdata(file);
T(T > 1) = 1;
nodeNames = importdata('nodesUSA.csv'); % Names of users n x str
c = csvread('comUSA.csv', 1, 2);
hashtags = readtable('nodesHashtagUSA.csv');
tagNames = table2array(hashtags);

%% france-by month data
% T = load('ByMounths/actFranceMounth4.csv'); % Says what users used what hashtags its n x t
% T(T > 1) = 1;
% nodeNames = importdata('nodesFrance.csv'); % Names of users n x str
% nodeNames = nodeNames.textdata;
% c = csvread('comFrance.csv', 1, 2);
% hashtags = readtable('nodesHashtagsFrance.csv');
% tagNames = table2array(hashtags);

%% delete users with few posts
idx_delete = (sum(T, 2) < 10);
T(idx_delete, :) = [];
c(idx_delete, :) = [];
nodeNames(idx_delete, :) = [];
%%

[n, t] = size(T);

%% add apart-together contraints
R = zeros(t, t);
R(2, 21) = 1; % Trump - trump
R(2, 48) = 1; % Trump - TRUMP
R(2, 20) = 1; % Trump - DonaldTrump
R(17, 29) = 1; % Clinton -ImWithHer
R(17, 24) = 1; % Clinton - Hillary
R(24, 28) = 1; % Hillary - HillaryClinton
R(1, 22) = 1; % GOPdebate - GOPdebate
R = R + R';

P = zeros(t, t);
P(13, 93) = 1; % Cruz - NeverCruz
P(2, 4) = 1; % Trump - NeverTrump
P(2, 24) = 1; % Trump - Hillary
P(2, 28) = 1; % Trump - HillaryClinton
P(4, 64) = 1; % NeverTrump - AlwaysTrump
P = P + P'; 

x = basic_apart_together_func(T, c, ones(t, 1), R, P, tagNames);
% the ones matrix ensures completely disjoint
explanations. To relax this (and allow w_i to be > 1 (see paper)) increase these
 entries

