亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? network.java

?? MASON代表多主體鄰里或網絡仿真(Multi-Agent Simulator of Neighborhoods or Networks)。它是喬治梅森大學用Java開發的離散事件多主體仿真核心庫
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
package sim.field.network;import sim.util.*;import java.util.*;/** The Network is a field which stores binary graph and multigraph structures of all kinds, using hash tables to allow    reasonably rapid dynamic modification.        <p>The nodes of a Network's graph can be any arbitrary, properly hashable object.  The edges of the    graph are members of the Edge class.  This class is little more than a wrapper around arbitrary object as well (the Edge's 'info'    object).  Thus your graph's nodes and edges can essentially be objects entirely of your choosing.        <p>Edge objects also contain pointers to the Nodes that they are to and from (plus some auxillary index information    for speed).        <p>Nodes and Edges are stored in the Network using two data structures: a Bag containing all the nodes in the Field;    and a HashMap which maps each Node to a container holding the Node's index in the Bag, plus a Bag of the Node's outgoing    Edges and a Bag of the Node's incoming Edges.  Ordinarily you won't fool with these structures other than to scan through    them (in particular, to scan rapidly through the allNodes bag rather than use an iterator).        <p>To add a node to the Network, simply use addNode(node).  To remove a node, use removeNode(node).    To add an edge to the Network, use addEdge(fromNode,toNode,edgeInfoObject), where edgeInfoObject is your    arbitrary edge object. Alternatively, you can make an Edge object from scratch and add it with addEdge(new Edge(fromNode, toNode, edgeInfoObject)).    You remove edges with removeEdge(edge).  If you add an edge, and its nodes have not been added yet, they will    automatically be added as well.        <p>Traversing a Network is easy.      To get a Bag of all the incoming (or outgoing) Edges to a node, use getEdgesIn(node) or getEdgesOut(node).    Do <b>not</b> add or remove Edges from this Bag -- it's used internally and we trust you here.  Also don't expect the    Bag to not change its values mysteriously later on.  Make a copy of the Bag if you want to keep it and/or modify it.    Once you have an Edge, you can call its to() method and from() methods to get the nodes it's from and to, and you can    at any time get and modify its info object.  The to() and from() are fast and inlined.        <p>However, the getEdgesIn(node) and getEdgesOut(node) methods are not super fast: they require a hash lookup.  If you    are planning on applying an algorithm on the Network which doesn't change the topology at all but traverses it a lot    and changes just the <b>contents</b> of the edge info objects and the node object contents, you might consider first     getting an adjacency list for the Network with getAdjacencyList(...), or an adjacency matrix with getAdjacencyMatrix(...)    or getMultigraphAdjacencyMatrix(...).  But remember that as soon as the topology changes (adding/deleting a node or edge),    the adjacency list is invalid, and you need to request another one.        <p><b>Computational Complexity.</b>  Adding a node or an edge is O(1).  Removing an edge is O(1).  Removing a node is O(m), where    m is the total number of edges in and out of the node.  Removing all nodes is O(1) and fast.  Getting the in-edges or out-edges for a node    is O(1).  Getting the to or from node for an edge is O(1) and fast.        <p><b>Warning About Hashing.</b>  Java's hashing method is broken in an important way.  One can override the hashCode() and equals()    methods of an object so that they hash by the value of an object rather than just the pointer to it.  But if this is done, then if    you use this object as a key in a hash table, then <i>change</i> those values in the object, it will break the hash table -- the key    and the object hashed by it will both be lost in the hashtable, unable to be accessed or removed from it.  The moral of the story is:    do not override hashCode() and equals() to hash by value unless your object is <i>immutable</i> -- its values cannot be changed.  This    is the case, for example, with Strings, which hash by value but cannot be modified.  It's also the case with Int2D, Int3D, Double2D,    and Double3D, as well as Double, Integer, etc.  Some of Sun's own objects are broken in this respect: Point, Point2D, etc. are both    mutable <i>and</i> hashed by value.        <p>This affects you in only one way in a Network: edges are hashed by nodes.  The Network permits you to use any object    as a node -- but you have been suitably warned: if you use a mutable but hashed-by-value node object, do NOT modify its values while    it's being used as a key in the Network.        <p><b>Directed vs. Undirected Graphs.</b>  Networks are constructed to be either directed or undirected, and they cannot be changed    afterwards.  If the network is directed, then an Edge's to() and from() nodes have explicit meaning: the Edge goes from() one node to()    another.  If the network is undirected, then to() and from() are simply the two nodes at each end of the Edge with no special meaning,    though they're always consistent.  The convenience method <i>edge</i>.getOtherNode(<i>node</i>) will provide "other" node (if node is to(),    then from() is returned, and vice versa).  This is particularly useful in undirected graphs where you could be entering an edge as to()    or as from() and you just want to know what the node on the other end of the edge is.            <p>There are three methods for getting all the edges attached to a node: getEdgesIn(), getEdgesOut(), and the less efficient getEdges().  These methods    work differently depending on whether or not the network is directed:            <p><table width="100%" border=0>    <tr><td><td><b>Directed</b><td><b>Undirected</b>    <tr><td><b>getEdgesIn()</b><td>Bag&nbsp;of&nbsp;incoming&nbsp;edges<td>Bag&nbsp;of&nbsp;all&nbsp;edges    <tr><td><b>getEdgesOut()</b><td>Bag&nbsp;of&nbsp;outgoing&nbsp;edges<td>Bag&nbsp;of&nbsp;all&nbsp;edges    <tr><td><b>getEdges()</b><td><i>Modifiable</i>&nbsp;Bag&nbsp;of&nbsp;all&nbsp;edges<td><i>Modifiable</i>&nbsp;Bag&nbsp;of&nbsp;all&nbsp;edges    </table>            <p><b>Hypergraphs.</b> Network is binary.  In the future we may provide a Hypergraph facility if it's needed, but for now you'll    need to make "multi-edge nodes" and store them in the field, then hook them to your nodes via Edges.  For example, to store the    relationship foo(node1, node2, node3), here's one way to do it:    <ol>    <li>Make a special foo object.    <li>field.addEdge(foo,node1,new Double(0));    <li>field.addEdge(foo,node2,new Double(1));    <li>field.addEdge(foo,node3,new Double(2));    </ol>*/public class Network implements java.io.Serializable    {    final public boolean directed;        /** Constructs a directed or undirected graph. */    public Network(boolean directed){this.directed = directed;  }    /** Constructs a directed graph */    public Network(){this(true); }                /** Hashes Network.IndexInOut structures by Node.  These structures        contain the incoming edges of the Node, its outgoing edges, and the index of        the Node in the allNodes bag. */    public HashMap indexOutInHash = new HashMap();    // perhaps rather than using a bag we should use an edge array... it'd be faster...    /** All the objects in the sparse field.  For fast scans.  Do not rely on this bag always being the same object. */    public Bag allNodes = new Bag();            // returned instead of null for those methods which require a guarantee that the returned Bag should never be touched.    final Bag emptyBag = new Bag();    /** Creates and returns an adjacency list.  If you're doing lots of operations (especially network traversals)        which won't effect the topology of the network, an adjacency list structure might be more efficient for you to access rather than lots of        calls to getEdgesIn() and getEdgesOut() etc.  Building the list is an O(#edges) operation.                <p>The adjacency list is an array of Edge arrays.  Each edge array holds all outgoing edges from a node        (if outEdges is true -- otherwise it's the incoming edges to the node).  The edge arrays are ordered in        their parent array in the same order that the corresponding nodes are ordered in the allNodes bag.                   <p>As soon as you modify any part of the Network's topology (through addEdge(), addNode(), removeEdge(),        removeNode(), removeAllNodes(), etc.), the adjacency list data is invalid and should not be used.  Instead, request        a new adjacency list.                 <p>You can modify these edge arrays any way you like, though the Edge objects are the actual Edges.    */    public Edge[][] getAdjacencyList(boolean outEdges)        {        final Edge[][] list = new Edge[allNodes.numObjs][];        for(int x=0;x<allNodes.numObjs;x++)            {            // load each list slot with an array consisting of all in or out edges for the node            final Bag edges =                 (outEdges ? getEdgesOut(allNodes.objs[x]) : getEdgesIn(allNodes.objs[x]));            list[x] = new Edge[edges.numObjs];            final Edge[] l = list[x];  // a little faster, one less level of indirection            final int n = edges.numObjs;  // likewiswe            final Object[] objs = edges.objs; // likewise            System.arraycopy(objs,0,l,0,n); // I don't know if this is faster or not, given the type mismatch -- Sean            /*            for(int y=0;y<n;y++)                          l[y] = (Edge)(objs[y]);  // hmmm, can we do an array copy across array types?            */            }        return list;        }            /** Creates and returns a simple adjacency matrix, where only one edge between any two nodes is considered -- if you're        using a multigraph, use getMultigraphAdjacencyMatrix() instead.  If you're doing lots of operations (especially network traversals)        which won't effect the topology of the network, an adjacency matrix structure might be more efficient for you to access rather than lots of        calls to getEdgesIn() and getEdgesOut() etc.  Building the matrix is an O(#edges + #nodes^2) operation.                <p>The adjacency matrix is a two-dimensional array of Edges, each dimension as long as the number of nodes in the graph.        Each entry in the array is either an Edge FROM a node TO another, or it is null (if there is no such edge).  If there are multiple        edges between any two nodes, an arbitrary one is chosen.  The Edge array returned is organized as Edge[FROM][TO].        The indices are ordered in the same order that the corresponding nodes are ordered in the allNodes bag.                   <p>As soon as you modify any part of the Network's topology (through addEdge(), addNode(), removeEdge(),        removeNode(), removeAllNodes(), etc.), the adjacency matrix data is invalid and should not be used.  Instead, request        a new adjacency matrix.                 <p>You can modify the array returned any way you like, though the Edge objects are the actual Edges.    */    public Edge[][] getAdjacencyMatrix()        {        final int n = allNodes.numObjs;        final Edge[][] matrix = new Edge[n][n];   // I assume it filled with nulls?        Iterator nodeIO = indexOutInHash.values().iterator();        while(nodeIO.hasNext()) // this replaces n hash lookups with n class casts            {            IndexOutIn ioi = (IndexOutIn)nodeIO.next();            if(ioi.out==null) continue;            int outDegree = ioi.out.numObjs;            Edge[] outEdges = matrix[ioi.index];            Object sourceNode =  allNodes.objs[ioi.index];                                    for(int i=0;i<outDegree;i++)                {                Edge e = (Edge)ioi.out.objs[i];                // this is getNodeIndex without the function call                outEdges[((IndexOutIn)indexOutInHash.get(e.getOtherNode(sourceNode))).index] = e;                }            }        return matrix;        }            /** Creates and returns a multigraph adjacency matrix, which includes all edges from a given node to another -- if you know for sure        that you have a simple graph (no multiple edges between two nodes), use getAdjacencyMatrix instead.          If you're doing lots of operations (especially network traversals) which won't effect the topology of the network, an         adjacency matrix structure might be more efficient for you to access rather than lots of calls to getEdgesIn() and         getEdgesOut() etc.  Building the matrix is expensive: it's an O(#edges + #nodes^2) operation.                <p>The adjacency matrix is a two-dimensional array of Edge arrays, both of the dimensions as long as the number of nodes in the graph.        Each entry in this two-dimensional array is an <b>array</b> of all edges FROM a node TO another.  Thus the        returned array structure is organized as Edge[FROM][TO][EDGES].        The FROM and TO indices are ordered in the same order that the corresponding nodes are ordered in the allNodes bag.            <p>Important note: if there are <i>no</i> edges FROM a given node TO another, an empty array is placed in that entry.        For efficiency's sake, the <i>same</i> empty array is used.  Thus you should not assume that you can compare edge arrays        for equality (an unlikely event anyway).                                                  <p>As soon as you modify any part of the Network's topology (through addEdge(), addNode(), removeEdge(),        removeNode(), removeAllNodes(), etc.), the adjacency matrix data is invalid and should not be used.  Instead, request        a new adjacency matrix.                 <p>You can modify the array returned any way you like, though the Edge objects are the actual Edges.    */    public Edge[][][] getMultigraphAdjacencyMatrix()        {        final int n = allNodes.numObjs;        final Edge[][][] matrix = new Edge[n][n][]; //I assume it filled with nulls?        Iterator nodeIO = indexOutInHash.values().iterator();        Bag[] tmp  = new Bag[n];        for(int i=0; i<n;i++)            tmp[i]=new Bag(n);                                while(nodeIO.hasNext()) // this replaces n hash lookups with n class casts            {            IndexOutIn ioi = (IndexOutIn)nodeIO.next();            if(ioi.out==null) continue;            int outDegree = ioi.out.numObjs;            Object sourceNode =  allNodes.objs[ioi.index];            for(int i=0;i<outDegree;i++)                {                Edge e = (Edge)ioi.out.objs[i];                //this is getNodeIndex without the function call                int j = ((IndexOutIn)indexOutInHash.get(e.getOtherNode(sourceNode))).index;                tmp[j].add(e);                }                                           Edge[][] outEdges = matrix[ioi.index];            for(int i=0;i<n;i++)                {                Bag b = tmp[i];                int ne = b.numObjs;                outEdges[i]=new Edge[ne];                if(ne>0)                    {                    System.arraycopy(b.objs,0,outEdges[i], 0, ne );                    b.clear();                    }                }                   }        //now the nodes with 0 out-degree have a row full of nulls in the matrix        for(int i=0;i<n;i++)            {            Edge[][] e2 = matrix[i];            if(e2[0]==null)                for(int j=0;j<n;j++)                    e2[j]=emptyEdgeArray;            }                         return matrix;        }            static Edge[] emptyEdgeArray = new Edge[0];//TODO do I want to use this? (ask liviu too)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美肥大bbwbbw高潮| 久久99精品国产.久久久久久| 亚洲午夜私人影院| 国内精品伊人久久久久av影院 | 麻豆成人av在线| 色悠悠亚洲一区二区| 欧美肥大bbwbbw高潮| 国产精品传媒视频| 激情六月婷婷久久| 欧美性色黄大片| 国产精品家庭影院| 韩国成人福利片在线播放| 欧美日韩国产综合一区二区| 亚洲乱码中文字幕综合| 国产福利一区二区三区视频在线| 欧美日韩aaaaaa| 亚洲午夜在线电影| caoporn国产一区二区| 26uuu色噜噜精品一区二区| 午夜精品免费在线观看| 色综合一个色综合亚洲| 一色屋精品亚洲香蕉网站| 国产一区二区三区四区五区美女| 欧美久久一区二区| 亚洲一区二区三区中文字幕 | 日韩理论片中文av| 粉嫩av一区二区三区粉嫩| 精品乱码亚洲一区二区不卡| 美女一区二区三区在线观看| 337p亚洲精品色噜噜| 亚洲一区二区三区爽爽爽爽爽| 色综合久久综合网| 一区二区三区资源| 色偷偷一区二区三区| 亚洲欧美日韩国产手机在线 | 国产麻豆精品久久一二三| 久久影院视频免费| 国产一区二区精品久久99| 精品捆绑美女sm三区| 久久国产尿小便嘘嘘| 欧美精品一区二区三区视频 | 91在线视频播放| 一区二区三区产品免费精品久久75| 91亚洲精华国产精华精华液| 亚洲人午夜精品天堂一二香蕉| 色综合天天综合狠狠| 亚洲无线码一区二区三区| 欧美狂野另类xxxxoooo| 久久99这里只有精品| 久久久久久99久久久精品网站| 国产不卡高清在线观看视频| 国产精品福利一区二区三区| 色综合天天综合狠狠| 日韩精品一二三| 欧美精品一区二区三区在线| 不卡av在线免费观看| 亚洲综合色噜噜狠狠| 欧美一区2区视频在线观看| 经典一区二区三区| 成人欧美一区二区三区白人| 欧美性xxxxxxxx| 久久99国产精品久久99| 国产精品久久久久影院亚瑟| 色婷婷久久综合| 蜜桃91丨九色丨蝌蚪91桃色| 中文字幕精品综合| 在线免费av一区| 激情亚洲综合在线| 日日摸夜夜添夜夜添精品视频| 欧美成人三级在线| 99re这里只有精品首页| 免费观看在线色综合| 中文字幕在线观看一区二区| 欧美日韩国产电影| 成人免费观看视频| 日本不卡视频在线| 综合久久国产九一剧情麻豆| 欧美videofree性高清杂交| 91在线精品一区二区三区| 丝袜美腿亚洲一区二区图片| 国产精品你懂的在线| 欧美久久久久免费| 99精品黄色片免费大全| 精品亚洲欧美一区| 亚洲午夜久久久| 中文字幕中文字幕一区二区| 91精品国产美女浴室洗澡无遮挡| 93久久精品日日躁夜夜躁欧美| 久久国产免费看| 日韩 欧美一区二区三区| 成人免费一区二区三区视频 | 欧美久久久影院| 色综合天天狠狠| 国产大片一区二区| 久久精品国产色蜜蜜麻豆| 一区二区三区日韩欧美精品| 欧美—级在线免费片| 欧美videossexotv100| 欧美精品99久久久**| 91黄视频在线观看| 91色乱码一区二区三区| 韩国欧美一区二区| 亚洲超碰97人人做人人爱| 最新热久久免费视频| 国产日产欧产精品推荐色| 精品国产91乱码一区二区三区| 欧美日本精品一区二区三区| 91免费在线视频观看| 不卡一区在线观看| av在线不卡网| 粉嫩高潮美女一区二区三区| 高清国产一区二区三区| 成人午夜视频在线| 99久久精品免费看国产| 99精品视频在线免费观看| 91在线免费视频观看| 91影院在线观看| 在线观看日韩电影| 欧美日韩在线观看一区二区 | 欧美精品一区二区三区四区 | 欧美一区二区三区系列电影| 欧美高清视频不卡网| 日韩区在线观看| 精品成人免费观看| 久久先锋资源网| 国产精品色哟哟| 亚洲欧美日韩在线| 亚洲va韩国va欧美va| 蜜桃91丨九色丨蝌蚪91桃色| 久久国产欧美日韩精品| 国产69精品久久久久毛片 | 一区二区三区日韩在线观看| 亚洲五码中文字幕| 久久99国产精品成人| 成人sese在线| 精品视频资源站| 日韩精品一区二区三区视频在线观看| 精品久久一区二区三区| 欧美激情中文字幕一区二区| 亚洲女女做受ⅹxx高潮| 亚洲大片精品永久免费| 韩国三级电影一区二区| zzijzzij亚洲日本少妇熟睡| 91色.com| 日韩一区二区中文字幕| 国产精品伦一区| 香蕉久久夜色精品国产使用方法| 麻豆国产一区二区| 99精品久久99久久久久| 欧美一区二区美女| 国产精品天美传媒沈樵| 天天色综合天天| 国产不卡免费视频| 在线综合视频播放| 中文字幕一区二区在线播放 | 99久久99久久久精品齐齐| 这里只有精品99re| 国产精品大尺度| 九九精品视频在线看| 91极品美女在线| 国产精品三级av在线播放| 日韩黄色在线观看| 91美女片黄在线观看91美女| www久久久久| 午夜视频在线观看一区二区三区 | 欧美三级日韩三级| 国产精品福利一区| 奇米色一区二区| 91福利在线观看| 久久久不卡影院| 麻豆91精品视频| 欧美三区在线观看| 亚洲天堂网中文字| 高清国产一区二区| 精品日韩av一区二区| 亚洲.国产.中文慕字在线| aaa国产一区| 久久精品视频一区二区| 蜜乳av一区二区| 欧美肥妇free| 亚洲一区二区偷拍精品| 色诱视频网站一区| 亚洲少妇屁股交4| 国产精一区二区三区| 欧美成人一区二区| 日本免费在线视频不卡一不卡二| 在线观看欧美精品| 亚洲精品水蜜桃| 一本一本大道香蕉久在线精品 | 91原创在线视频| 国产精品久久久久久久久果冻传媒 | 中文字幕av资源一区| 韩国视频一区二区| www国产成人免费观看视频 深夜成人网| 亚洲在线中文字幕| 欧美性猛片aaaaaaa做受| 亚洲区小说区图片区qvod| 99re成人精品视频| 亚洲女爱视频在线| 欧美性猛交xxxxxx富婆|