📄 demosimilaritygraphs.m
字号:
function varargout = DemoSimilarityGraphs(varargin)% Usage: DemoSimilarityGraphs()% % Opens a large window, with all sorts of knobs and sliders. Just play :-) % % Documentation can be found at the GraphDemo webpage. % Written by Matthias Hein and Ulrike von Luxburg% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @DemoSimilarityGraphs_OpeningFcn, ... 'gui_OutputFcn', @DemoSimilarityGraphs_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before DemoSimilarityGraphs is made visible.function DemoSimilarityGraphs_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to DemoSimilarityGraphs (see VARARGIN)% Choose default command line output for DemoSimilarityGraphshandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes DemoSimilarityGraphs wait for user response (see UIRESUME)% uiwait(handles.figure1);% ------------------------------------------------------------% ULE begin initializing % do this within this function as it only has to happen once% ------------------------------------------------------------% ULE: % to avoid the following weird error message: % Warning: RGB color data not yet supported in Painter's mode.% is due to automatic choice of renderer by matlab. set(gcf, 'Renderer', 'Zbuffer')warning('off','MATLAB:dispatcher:InexactMatch')global GD_Global;GD_Global = struct('CurrentNumPoints',100, 'MinNumPoints',10, 'MaxNumPoints',500, ... 'CurrentDataDim',2, 'MinDataDim',2, 'MaxDataDim',200,... 'CurrentDataSet',1, ... %referst to position in list 'CurrentSimFct','Gaussian kernel',... 'CurrentGraph1', 1, ... %refers to position in list, 1=eps 'CurrentGraph2',2,... %refers to position in list, 2 = symm knn 'CurrentGraphPara1',0.5,... 'CurrentGraphPara2',5, ... 'DefaultK',5,'DefaultEps',0.5,... %default para values 'CurrentSigma',0.5, 'MinLogSigma',-2, 'MaxLogSigma',2, ... %sigma of the similarity function 'DefaultSigma',0.5, ... 'CurrentVarNoise',0.01, 'MinVarNoise',0,'MaxVarNoise',0.1,... 'MinK', 1, 'MaxK',50, 'MinEps', 0, 'MaxEps',100, ... 'points', [], 'labels', [] , ... %data set 'D', [], ... % data distance matrix 'S', [], ... %data similarity matrix 'W1', [], ... %adjacency matrix of first graph 'W2',[]); %adjacency matrix of second graph % set colormap, this is the one implicitly used everywhere: % note that a colormap refers to a figure, not to an axis; cannot choose different % colormaps in different axes of the same figure%set(0, 'colormap',autumn)% somehow does not really work, gets reset all the time, giving up. % set data sliders to their default values, and edit the min/max texts: InitializeSliders(handles)% draw data set: DrawDataAndPlot(handles)% compute new similarity function: ComputeSimilarityAndPlot(handles)% plot the graphs a first time: ComputeGraphAndPlot(handles, 1)ComputeGraphAndPlot(handles, 2)% ------------------------------------------------------------% ULE end initializing% ------------------------------------------------------------% --- Outputs from this function are returned to the command line.function varargout = DemoSimilarityGraphs_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout{1} = handles.output;% --- Executes on selection change in type_graph2.function type_graph2_Callback(hObject, eventdata, handles)% hObject handle to type_graph2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns type_graph2 contents as cell array% contents{get(hObject,'Value')} returns selected item from type_graph2%ULE:global GD_Global; GD_Global.CurrentGraph2 =get(hObject,'Value') ;% set values back to default:switch GD_Global.CurrentGraph2 case 1 GD_Global.CurrentGraphPara2 = SelectGoodEps(handles); case 2 GD_Global.CurrentGraphPara2 = GD_Global.DefaultK; case 3 GD_Global.CurrentGraphPara2 = GD_Global.DefaultK; case 4 GD_Global.CurrentGraphPara2 = SelectGoodEps(handles); endInitializeSliders(handles);% --- Executes during object creation, after setting all properties.function type_graph2_CreateFcn(hObject, eventdata, handles)% hObject handle to type_graph2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: popupmenu controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end% ULE: note that the entries in the popup menue have been defined in the property editor in the string property% --- Executes on slider movement.function slider_graph_para2_Callback(hObject, eventdata, handles)% hObject handle to slider_graph_para2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slider%ULE:global GD_Global; GD_Global.CurrentGraphPara2 =get(hObject,'Value') ;InitializeSliders(handles);% --- Executes during object creation, after setting all properties.function slider_graph_para2_CreateFcn(hObject, eventdata, handles)% hObject handle to slider_graph_para2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on selection change in type_graph1.function type_graph1_Callback(hObject, eventdata, handles)% hObject handle to type_graph1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns type_graph1 contents as cell array% contents{get(hObject,'Value')} returns selected item from type_graph1%ULE:global GD_Global; GD_Global.CurrentGraph1 =get(hObject,'Value') ;% set values back to default:switch GD_Global.CurrentGraph1 case 1 % try to choose a useful eps in the first place: GD_Global.CurrentGraphPara1 = SelectGoodEps(handles); case 2 GD_Global.CurrentGraphPara1 = GD_Global.DefaultK; case 3 GD_Global.CurrentGraphPara1 = GD_Global.DefaultK; case 4 GD_Global.CurrentGraphPara1 = SelectGoodEps(handles); endInitializeSliders(handles);% --- Executes during object creation, after setting all properties.function type_graph1_CreateFcn(hObject, eventdata, handles)% hObject handle to type_graph1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: popupmenu controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end% --- Executes on slider movement.function slider_graph_para1_Callback(hObject, eventdata, handles)% hObject handle to slider_graph_para1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slider%ULE:global GD_Global; GD_Global.CurrentGraphPara1 =get(hObject,'Value') ;InitializeSliders(handles);% --- Executes during object creation, after setting all properties.function slider_graph_para1_CreateFcn(hObject, eventdata, handles)% hObject handle to slider_graph_para1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on selection change in select_data_set.function select_data_set_Callback(hObject, eventdata, handles)% hObject handle to select_data_set (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns select_data_set contents as cell array% contents{get(hObject,'Value')} returns selected item from select_data_setglobal GD_Global; GD_Global.CurrentDataSet =get(hObject,'Value') ;InitializeSliders(handles);% DrawDataAndPlot(handles); % ComputeSimilarityAndPlot(handles);% ComputeGraphAndPlot(handles, 1)% ComputeGraphAndPlot(handles, 2)% --- Executes during object creation, after setting all properties.function select_data_set_CreateFcn(hObject, eventdata, handles)% hObject handle to select_data_set (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: popupmenu controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end% --- Executes on slider movement.function slider_num_points_Callback(hObject, eventdata, handles)% hObject handle to slider_num_points (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slider% ULE: global GD_Global; GD_Global.CurrentNumPoints = ceil(get(hObject,'Value'));InitializeSliders(handles);% DrawDataAndPlot(handles); % ComputeSimilarityAndPlot(handles); % ComputeGraphAndPlot(handles, 1)% ComputeGraphAndPlot(handles, 2)% --- Executes during object creation, after setting all properties.function slider_num_points_CreateFcn(hObject, eventdata, handles)% hObject handle to slider_num_points (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function slider_num_dim_Callback(hObject, eventdata, handles)% hObject handle to slider_num_dim (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -