⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graphgiubrowsegraph.m

📁 复杂网络的一些节点面对攻击的代码
💻 M
📖 第 1 页 / 共 4 页
字号:
function GraphGIUBrowseGraph_PathDetailsSlider_ButtonDown(h, eventdata, handles, varargin)
fig = FigureHandle(h);
if ~isempty(fig)
    try
        global GraphGUIBrowseGraphData;
        if ~isempty(GraphGUIBrowseGraphData)
            Position = get( GraphGUIBrowseGraphData.PathDetailsSlider,'Value');
            W = (GraphGUIBrowseGraphData.Properties.NodeDetailsListBoxWidth+GraphGUIBrowseGraphData.Properties.NodeDetailsListBoxGap);
            for i = 1 : numel(GraphGUIBrowseGraphData.PathDetails.Elements)
                ListboxSz = get(GraphGUIBrowseGraphData.PathDetails.Elements{i},'Position');
                ListboxSz(1) = Position + (i-1)*W;
                set(GraphGUIBrowseGraphData.PathDetails.Elements{i},'Position',ListboxSz);
                AdjustBrowseControls(h,i);
            end
        end
    catch
    end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function AdjustBrowseControls(h,Index)
fig = FigureHandle(h);
if ~isempty(fig)
    try
        global GraphGUIBrowseGraphData;
        if ~isempty(GraphGUIBrowseGraphData)
            ListboxSz = get(GraphGUIBrowseGraphData.PathDetails.Elements{Index},'Position');
            SzButton = get(GraphGUIBrowseGraphData.PathDetails.ScrollButtons{1,Index},'Position');
            SzButton(1) = ListboxSz(1);
            set( GraphGUIBrowseGraphData.PathDetails.ScrollButtons{1,Index},'Position',SzButton);
            SzButton(1) = SzButton(1)+SzButton(3);
            set( GraphGUIBrowseGraphData.PathDetails.ScrollButtons{2,Index},'Position',SzButton);
            SzButton(1) = SzButton(1)+SzButton(3);
            set( GraphGUIBrowseGraphData.PathDetails.Text{Index},'Position',SzButton);
            % GraphGUIBrowseGraphData.PathDetails.Text{Index};
            Visibility = SetChildVisibility(GraphGUIBrowseGraphData.PathBrowserPanel,GraphGUIBrowseGraphData.PathDetails.Elements{Index});
            set(GraphGUIBrowseGraphData.PathDetails.ScrollButtons{1,Index},'Visible',Visibility);
            set(GraphGUIBrowseGraphData.PathDetails.ScrollButtons{2,Index},'Visible',Visibility);
            set(GraphGUIBrowseGraphData.PathDetails.Text{Index},'Visible',Visibility);
        end
    catch
    end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Indeces, NumberOfElements]= FindLinkedElements(h,Tag,FindAll)
try
    global GraphGUIBrowseGraphData;
    if ~isempty(GraphGUIBrowseGraphData)
        if Tag == 1
            NumberOfElements  = numel(GraphGUIBrowseGraphData.PathDetails.NodeIDs);
            SortOrder = GetSortOrder(h,GraphGUIBrowseGraphData.PathDetails.NodeIDs);
        else
            Selected = GetVariable(h);
            NodeID = GraphGUIBrowseGraphData.PathDetails.Path{Tag-1};
            Direction = get(GraphGUIBrowseGraphData.BrowseDirectionPopup,'String');
            Direction = Direction{ get(GraphGUIBrowseGraphData.BrowseDirectionPopup,'Value') };
            Neighbours = evalin('base',['GraphGetNodeNeighbours(' Selected  ',' num2str(NodeID)  ',''' Direction ''')']);
            NumberOfElements  = numel(Neighbours );
            SortOrder = GetSortOrder(h,Neighbours );
            Neighbours = Neighbours (SortOrder);
        end
        if ~exist('FindAll','var') | FindAll==0
            Indeces = GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag) :  GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag)+GraphGUIBrowseGraphData.Properties.MaxNumberOfListElements-1;
            Indeces (Indeces >NumberOfElements) = [];
        else
            Indeces = 1 : NumberOfElements;
        end                
        if Tag == 1
            Indeces = SortOrder(Indeces);
         %   GraphGUIBrowseGraphData.PathDetails.NodeNames = GraphGUIBrowseGraphData.PathDetails.NodeNames(SortOrder);
         %   GraphGUIBrowseGraphData.PathDetails.NodeIDs    =   GraphGUIBrowseGraphData.PathDetails.NodeIDs(SortOrder);
        else
            GraphGUIBrowseGraphData.Neighbours = Neighbours(Indeces);
            evalin('base',['global GraphGUIBrowseGraphData;']);
            [Neighbours Indeces  ib] = evalin('base',['intersect(GraphGUIBrowseGraphData.PathDetails.NodeIDs, GraphGUIBrowseGraphData.Neighbours)']);
        end
    end
catch
    Indeces = [];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function  GraphGIUBrowseGraph_ScrollListbox_PushDown(h, eventdata, handles, varargin)
fig = FigureHandle(h);
if ~isempty(fig)
    try
        global GraphGUIBrowseGraphData;
        if ~isempty(GraphGUIBrowseGraphData)
            Tag = str2num(get(h,'Tag'));            
            if  strcmp(get(h,'Style'),'pushbutton')  &  ~isempty(strfind(get(h,'String'),'>>'))
                GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag)  = GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag) +GraphGUIBrowseGraphData.Properties.MaxNumberOfListElements;
%                 if GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag) > NumberOfElements - GraphGUIBrowseGraphData.Properties.MaxNumberOfListElements
%                     GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag) = NumberOfElements - GraphGUIBrowseGraphData.Properties.MaxNumberOfListElements;
%                 end
            elseif strcmp(get(h,'Style'),'pushbutton')   & ~isempty(strfind(get(h,'String'),'<<'))
                GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag) = GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag)-GraphGUIBrowseGraphData.Properties.MaxNumberOfListElements;
                if GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag)<=0
                    GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag) = 1;
                end
            end           
            [Indeces, NumberOfElements]= FindLinkedElements(h,Tag);
            if isempty(Indeces) & NumberOfElements>0
                GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag) = 1;
                [Indeces, NumberOfElements]= FindLinkedElements(h,Tag);
            end
            ListBoxString = strcat( GraphGUIBrowseGraphData.PathDetails.NodeNames(Indeces), '    (', num2str(GraphGUIBrowseGraphData.PathDetails.NodeIDs(Indeces)), ')');
            
            set ( GraphGUIBrowseGraphData.PathDetails.Elements{Tag},'String',ListBoxString);
            set(GraphGUIBrowseGraphData.PathDetails.Text{Tag},'String',num2str(NumberOfElements));

            %  eval(get ( GraphGUIBrowseGraphData.PathDetails.Elements{Tag},'Callback'));
        end
    catch
    end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function  GraphGIUBrowseGraph_NodeListBox_Select(h, eventdata, handles, varargin)
fig = FigureHandle(h);
if ~isempty(fig)
    try
        global GraphGUIBrowseGraphData;
        % Properties  =   Data.Properties;
        if ~isempty(GraphGUIBrowseGraphData)
            Tag = str2num(get(h,'Tag'));
            [Indeces, NumberOfElements]= FindLinkedElements(h,Tag);
            Value = get(h,'Value');%  + GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag)-1;
            NodeID = Indeces(Value);
            % NodeID = GraphGUIBrowseGraphData.PathDetails.NodeIDs(Value);
            set(GraphGUIBrowseGraphData.NodeDetailsEdit,'String',GetGraphNodeDetails(fig,NodeID));
            for i = Tag + 1 : numel(GraphGUIBrowseGraphData.PathDetails.Elements)
                delete (GraphGUIBrowseGraphData.PathDetails.Elements{i});
                delete (GraphGUIBrowseGraphData.PathDetails.ScrollButtons{1,i});
                delete (GraphGUIBrowseGraphData.PathDetails.ScrollButtons{2,i});
                delete (GraphGUIBrowseGraphData.PathDetails.Text{i});
            end
            GraphGUIBrowseGraphData.PathDetails.Elements(Tag+1:end) = [];
            GraphGUIBrowseGraphData.PathDetails.ScrollButtons(:,Tag+1:end) = [];
            GraphGUIBrowseGraphData.PathDetails.ScrollPosition(:,Tag+1:end) = [];
            GraphGUIBrowseGraphData.PathDetails.Text(Tag+1:end)  = [];
            GraphGUIBrowseGraphData.PathDetails.Path(Tag:end) = [];
            GraphGUIBrowseGraphData.PathDetails.Path(Tag+1:end) = [];
            AddNodeToPath(h,NodeID);
        end
    catch
    end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function AddNodeToPath(h,NodeID)
fig = FigureHandle(h);
if ~isempty(fig)
    try
        global GraphGUIBrowseGraphData;
        % Properties  =   Data.Properties;
        % Add box:

        Sz = get(GraphGUIBrowseGraphData.PathBrowserPanel,'Position');        
        
%        W = (GraphGUIBrowseGraphData.Properties.NodeDetailsListBoxWidth+GraphGUIBrowseGraphData.Properties.NodeDetailsListBoxGap);
        if numel(GraphGUIBrowseGraphData.PathDetails.Elements)>0
            PrevSz = get(GraphGUIBrowseGraphData.PathDetails.Elements{end},'Position');
            PrevWs  = PrevSz(1)+PrevSz(3)+GraphGUIBrowseGraphData.Properties.NodeDetailsListBoxGap;
        else
            PrevWs = 2;
        end
        Sz = [ PrevWs  GraphGUIBrowseGraphData.Properties.ScrollBarWidth+2+GraphGUIBrowseGraphData.Properties.ButtonSize(2) GraphGUIBrowseGraphData.Properties.NodeDetailsListBoxWidth Sz(4)-3-GraphGUIBrowseGraphData.Properties.ButtonSize(2)];
        NewListBox =   uicontrol(fig,'Style','listbox','Units','Points','Position',round(Sz),...
            'Visible','on','Tag',num2str(numel(GraphGUIBrowseGraphData.PathDetails.Elements)+1),'String','', ...
            'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_NodeListBox_Select'',gcbo,[],guidata(gcbo));'...
            );
        set(NewListBox ,GraphGUIBrowseGraphData.Properties.Font);
        if exist('NodeID','var')  & ~isempty(NodeID)
            if ~isempty(GraphGUIBrowseGraphData)
                if isnumeric(NodeID)
                    NodeName = GraphGUIBrowseGraphData.PathDetails.NodeNames{find(GraphGUIBrowseGraphData.PathDetails.NodeIDs==NodeID)};
                else
                    NodeName = NodeID;
                    NodeID = GraphGUIBrowseGraphData.PathDetails.NodeIDs(strmatch(NodeID,GraphGUIBrowseGraphData.PathDetails.NodeNames,'exact'));
                end
            end
            GraphGUIBrowseGraphData.PathDetails.Path{end+1} = NodeID;
        end
        Sz = get(NewListBox ,'Position');
        Sz = [Sz(1) Sz(2)-GraphGUIBrowseGraphData.Properties.ButtonSize(2) GraphGUIBrowseGraphData.Properties.ButtonSize(1) GraphGUIBrowseGraphData.Properties.ButtonSize(2)];
        GraphGUIBrowseGraphData.PathDetails.ScrollButtons{end+1} =  uicontrol(fig,'Style','pushbutton','Units','Points','Position',round(Sz),...
            'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_ScrollListbox_PushDown'',gcbo,[],guidata(gcbo));',...
            'Visible','on','Tag',num2str(numel(GraphGUIBrowseGraphData.PathDetails.Elements)+1),'String','<< Back'...
            );
        Sz = [Sz(1)+GraphGUIBrowseGraphData.Properties.ButtonSize(1) Sz(2) GraphGUIBrowseGraphData.Properties.ButtonSize(1) GraphGUIBrowseGraphData.Properties.ButtonSize(2)];
        GraphGUIBrowseGraphData.PathDetails.ScrollButtons{end+1}=  uicontrol(fig,'Style','pushbutton','Units','Points','Position',round(Sz),...
            'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_ScrollListbox_PushDown'',gcbo,[],guidata(gcbo));',...
            'Visible','on','Tag',num2str(numel(GraphGUIBrowseGraphData.PathDetails.Elements)+1),'String','Forward >>'...
            );
        Sz(1)  = Sz(1) + Sz(3);
        GraphGUIBrowseGraphData.PathDetails.Text{end+1} = uicontrol(fig,'Style','text','Units','Points','Position',round(Sz),...
            'Visible','on','Tag',num2str(numel(GraphGUIBrowseGraphData.PathDetails.Elements)+1),'String',''...
            );
        GraphGUIBrowseGraphData.PathDetails.ScrollButtons = reshape(GraphGUIBrowseGraphData.PathDetails.ScrollButtons,[2 numel(GraphGUIBrowseGraphData.PathDetails.ScrollButtons)/2]);
        GraphGUIBrowseGraphData.PathDetails.ScrollPosition(end+1) = 1;
        GraphGUIBrowseGraphData.PathDetails.Elements{end+1} = NewListBox;
        GraphGIUBrowseGraph_ScrollListbox_PushDown( GraphGUIBrowseGraphData.PathDetails.ScrollButtons{end-1} );
        if  numel(GraphGUIBrowseGraphData.PathDetails.Elements) < 2
            set(GraphGUIBrowseGraphData.PathDetailsSlider,'Enable','off');
        else
            ListboxSz = get(NewListBox,'Position');
            ClientSz = get(GraphGUIBrowseGraphData.PathBrowserPanel,'Position');
            Shift = (ListboxSz (1)+ListboxSz (3) ) - (ClientSz  (1)+ClientSz (3));
            if Shift>0
                for i = 1 : numel(GraphGUIBrowseGraphData.PathDetails.Elements)
                    Sz = get( GraphGUIBrowseGraphData.PathDetails.Elements{i},'Position');
                    Sz(1) = Sz(1)-Shift;
                    set( GraphGUIBrowseGraphData.PathDetails.Elements{i},'Position',Sz);
                    SzButton = get(GraphGUIBrowseGraphData.PathDetails.ScrollButtons{1,i},'Position');
                    SzButton(1) = Sz(1);
                    set( GraphGUIBrowseGraphData.PathDetails.ScrollButtons{1,i},'Position',SzButton);
                    SzButton(1) = SzButton(1)+SzButton(3);
                    set( GraphGUIBrowseGraphData.PathDetails.ScrollButtons{2,i},'Position',SzButton);
                    SzButton(1) = SzButton(1)+SzButton(3);
                    set(GraphGUIBrowseGraphData.PathDetails.Text{i},'Position',SzButton);

                    Visibility = SetChildVisibility(GraphGUIBrowseGraphData.PathBrowserPanel,GraphGUIBrowseGraphData.PathDetails.Elements{i});
                    set(GraphGUIBrowseGraphData.PathDetails.ScrollButtons{1,i},'Visible',Visibility);
                    set(GraphGUIBrowseGraphData.PathDetails.ScrollButtons{2,i},'Visible',Visibility);
                    set(GraphGUIBrowseGraphData.PathDetails.Text{i},'Visible',Visibility);
                end
            end
            TotalWidth = 0;
            SzFirst = get(GraphGUIBrowseGraphData.PathDetails.Elements{1},'Position');
            SzLast = get(GraphGUIBrowseGraphData.PathDetails.Elements{end},'Position');
            TotalWidth = SzLast(1)+SzLast(3)-SzFirst(1);
            set(GraphGUIBrowseGraphData.PathDetailsSlider,'Enable','on');
            % TO DO: SET THE SLIDER VALUE.
            set(GraphGUIBrowseGraphData.PathDetailsSlider,'Max',2,'Min',-TotalWidth,'Value', SzFirst(1));
        end
    catch
    end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -